From: Ken Thompson Date: Mon, 8 Sep 2008 20:10:11 +0000 (-0700) Subject: bug with struct literal with metods X-Git-Tag: weekly.2009-11-06~3267 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=077fe40867d1d150ce0a9f2ffa00f939641734c8;p=gostls13.git bug with struct literal with metods R=r OCL=14937 CL=14937 --- diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index 6826e19035..37c3ccd742 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -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; }