From 077fe40867d1d150ce0a9f2ffa00f939641734c8 Mon Sep 17 00:00:00 2001 From: Ken Thompson Date: Mon, 8 Sep 2008 13:10:11 -0700 Subject: [PATCH] bug with struct literal with metods R=r OCL=14937 CL=14937 --- src/cmd/gc/walk.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; } -- 2.48.1