Commit 546f269c authored by Rob Pike's avatar Rob Pike

if the typestring gives a field name of "?", drop it.

R=rsc
DELTA=11  (7 added, 0 deleted, 4 changed)
OCL=20988
CL=20988
parent ac09eb4f
......@@ -118,7 +118,7 @@ export func TestAll(tt *testing.T) { // TODO(r): wrap up better
typedump("*chan<-string", "*chan<-string");
typedump("struct {c *chan *int32; d float32}", "struct{c *chan*int32; d float32}");
typedump("*(a int8, b int32)", "*(a int8, b int32)");
typedump("struct {c *(? *chan *P.integer, ? *int8)}", "struct{c *(? *chan*P.integer, ? *int8)}");
typedump("struct {c *(? *chan *P.integer, ? *int8)}", "struct{c *(*chan*P.integer, *int8)}");
typedump("struct {a int8; b int32}", "struct{a int8; b int32}");
typedump("struct {a int8; b int8; b int32}", "struct{a int8; b int8; b int32}");
typedump("struct {a int8; b int8; c int8; b int32}", "struct{a int8; b int8; c int8; b int32}");
......@@ -149,7 +149,7 @@ export func TestAll(tt *testing.T) { // TODO(r): wrap up better
valuedump("*chan<-string", "*chan<-string(0)");
valuedump("struct {c *chan *int32; d float32}", "struct{c *chan*int32; d float32}{*chan*int32(0), 0}");
valuedump("*(a int8, b int32)", "*(a int8, b int32)(0)");
valuedump("struct {c *(? *chan *P.integer, ? *int8)}", "struct{c *(? *chan*P.integer, ? *int8)}{*(? *chan*P.integer, ? *int8)(0)}");
valuedump("struct {c *(? *chan *P.integer, ? *int8)}", "struct{c *(*chan*P.integer, *int8)}{*(*chan*P.integer, *int8)(0)}");
valuedump("struct {a int8; b int32}", "struct{a int8; b int32}{0, 0}");
valuedump("struct {a int8; b int8; b int32}", "struct{a int8; b int8; b int32}{0, 0, 0}");
......
......@@ -47,7 +47,10 @@ func TypeFieldsToString(t HasFields, sep string) string {
var str string;
for i := 0; i < t.Len(); i++ {
str1, typ, tag, offset := t.Field(i);
str1 += " " + TypeToString(typ, false);
if str1 != "" {
str1 += " "
}
str1 += TypeToString(typ, false);
if tag != "" {
str1 += " " + DoubleQuote(tag);
}
......
......@@ -690,7 +690,11 @@ func (p *Parser) Fields(sep, term string) *[]Field {
}
a = a1;
}
a[nf].name = p.token;
name := p.token;
if name == "?" { // used to represent a missing name
name = ""
}
a[nf].name = name;
p.Next();
a[nf].typ = p.Type("");
if p.token != "" && p.token[0] == '"' {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment