]> Cypherpunks repositories - gostls13.git/commitdiff
if the typestring gives a field name of "?", drop it.
authorRob Pike <r@golang.org>
Thu, 11 Dec 2008 21:24:04 +0000 (13:24 -0800)
committerRob Pike <r@golang.org>
Thu, 11 Dec 2008 21:24:04 +0000 (13:24 -0800)
R=rsc
DELTA=11  (7 added, 0 deleted, 4 changed)
OCL=20988
CL=20988

src/lib/reflect/all_test.go
src/lib/reflect/tostring.go
src/lib/reflect/type.go

index bb851d49e6bcfb53ae0e18440843ee6701c75c25..fe16a82f5b97f5571c449c1682c0927831e6765e 100644 (file)
@@ -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}");
 
index 8d2d7642446773c9d062ea13832c36583d11eb09..5e658a13041178999cdab85b5a625957e469e1f1 100644 (file)
@@ -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);
                }
index ce44ecf937d2d73eeae2b64a9f817b6d29b26512..f1bbe42b822cf50e413d21ca6d62ef6c93a8309a 100644 (file)
@@ -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] == '"' {