]> Cypherpunks repositories - gostls13.git/commitdiff
bug with struct literal with metods
authorKen Thompson <ken@golang.org>
Mon, 8 Sep 2008 20:10:11 +0000 (13:10 -0700)
committerKen Thompson <ken@golang.org>
Mon, 8 Sep 2008 20:10:11 +0000 (13:10 -0700)
R=r
OCL=14937
CL=14937

src/cmd/gc/walk.c

index 6826e1903535f73a2e7b0d304bb2fd66e785e12d..37c3ccd7426d051634e306217696bf296146e793 100644 (file)
@@ -2882,9 +2882,17 @@ structlit(Node *n)
        r = listfirst(&saver, &n->left);
 
 loop:
+       if(l != T && l->etype == TFIELD && l->type->etype == TFUNC) {
+               // skip methods
+               l = structnext(&savel);
+               goto loop;
+       }
+
        if(l == T || r == N) {
-               if(l != T || r != N)
-                       yyerror("error in shape struct literal");
+               if(l != T)
+                       yyerror("struct literal expect expr of type %T", l);
+               if(r != N)
+                       yyerror("struct literal too many expressions");
                return var;
        }