From 7743ffead4d8e89256931649dd04912121833f51 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 28 Sep 2009 14:05:34 -0700 Subject: [PATCH] disallow interface { x, y() } R=ken OCL=35042 CL=35044 --- src/cmd/gc/go.y | 19 +++++++++---------- test/fixedbugs/bug121.go | 5 ++++- test/ken/embed.go | 12 ++++++------ test/ken/interfun.go | 3 ++- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/cmd/gc/go.y b/src/cmd/gc/go.y index af7285d4a39..9aa2f1ab089 100644 --- a/src/cmd/gc/go.y +++ b/src/cmd/gc/go.y @@ -54,7 +54,7 @@ %type expr_or_type %type fndcl fnliteral %type for_body for_header for_stmt if_header if_stmt -%type keyval labelname name +%type interfacedcl keyval labelname name %type name_or_type non_expr_type %type new_name dcl_name oexpr typedclname %type onew_name @@ -67,7 +67,7 @@ %type xdcl fnbody fnres switch_body loop_body dcl_name_list %type new_name_list expr_list keyval_list braced_keyval_list expr_or_type_list xdcl_list %type oexpr_list oexpr_or_type_list caseblock_list stmt_list oarg_type_list arg_type_list -%type interfacedcl_list interfacedcl vardcl vardcl_list structdcl structdcl_list +%type interfacedcl_list vardcl vardcl_list structdcl structdcl_list %type common_dcl constdcl constdcl1 constdcl_list typedcl_list %type convtype dotdotdot @@ -1226,9 +1226,12 @@ structdcl_list: interfacedcl_list: interfacedcl + { + $$ = list1($1); + } | interfacedcl_list ';' interfacedcl { - $$ = concat($1, $3); + $$ = list($1, $3); } structdcl: @@ -1284,17 +1287,13 @@ embed: } interfacedcl: - new_name_list indcl + new_name indcl { - NodeList *l; - - for(l=$1; l; l=l->next) - l->n = nod(ODCLFIELD, l->n, $2); - $$ = $1; + $$ = nod(ODCLFIELD, $1, $2); } | packname { - $$ = list1(nod(ODCLFIELD, N, oldname($1))); + $$ = nod(ODCLFIELD, N, oldname($1)); } indcl: diff --git a/test/fixedbugs/bug121.go b/test/fixedbugs/bug121.go index 7bd721815dd..71d3ee4252e 100644 --- a/test/fixedbugs/bug121.go +++ b/test/fixedbugs/bug121.go @@ -9,7 +9,10 @@ package main type T func() type I interface { - f, g (); + f, g (); // ERROR "syntax|signature" +} + +type J interface { h T; // ERROR "syntax|signature" } diff --git a/test/ken/embed.go b/test/ken/embed.go index 8f4641e8116..5978f7747fd 100644 --- a/test/ken/embed.go +++ b/test/ken/embed.go @@ -10,12 +10,12 @@ package main type I interface { - test1, - test2, - test3, - test4, - test5, - test6, + test1() int; + test2() int; + test3() int; + test4() int; + test5() int; + test6() int; test7() int; }; diff --git a/test/ken/interfun.go b/test/ken/interfun.go index 876d94128dc..c508c73c302 100644 --- a/test/ken/interfun.go +++ b/test/ken/interfun.go @@ -18,7 +18,8 @@ type I1 interface type I2 interface { - g,f ()int; + g() int; + f() int; } func