]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/gc: blank methods are not permitted in interface types
authorChris Manghane <cmang@golang.org>
Wed, 15 Oct 2014 16:55:13 +0000 (09:55 -0700)
committerChris Manghane <cmang@golang.org>
Wed, 15 Oct 2014 16:55:13 +0000 (09:55 -0700)
Fixes #6606.

LGTM=rsc
R=rsc
CC=golang-codereviews, gri
https://golang.org/cl/156210044

src/cmd/gc/dcl.c
test/interface/explicit.go
test/interface/fail.go

index cc010d901cb7f1e003d3c36ae6ba9a7ea93dc16b..dfcf47520ac3d3e0d0f1030ad8881e15c0cc0714 100644 (file)
@@ -558,6 +558,9 @@ ifacedcl(Node *n)
        if(n->op != ODCLFIELD || n->right == N)
                fatal("ifacedcl");
 
+       if(isblank(n->left))
+               yyerror("methods must have a unique non-blank name");
+
        dclcontext = PPARAM;
        markdcl();
        funcdepth++;
index 36fa1a4224f9d329981390c5ba11d1aa6448d55e..b10d02f2485adb66c1411351ce4909661325ef6d 100644 (file)
@@ -83,12 +83,12 @@ var m4 = M(jj) // ERROR "invalid|wrong type for M method"
 
 
 type B1 interface {
-       _()
+       _() // ERROR "methods must have a unique non-blank name"
 }
 
 type B2 interface {
        M()
-       _()
+       _() // ERROR "methods must have a unique non-blank name"
 }
 
 type T2 struct{}
index 81eb6cb3c151958b9193526c5e25f5941ef4cb42..d40a1513832115bc8c3d015575126d14141f564d 100644 (file)
@@ -14,7 +14,6 @@ type I interface {
 
 func main() {
        shouldPanic(p1)
-       shouldPanic(p2)
 }
 
 func p1() {
@@ -30,19 +29,6 @@ type S struct{}
 
 func (s *S) _() {}
 
-type B interface {
-       _()
-}
-
-func p2() {
-       var s *S
-       var b B
-       var e interface{}
-       e = s
-       b = e.(B)
-       _ = b
-}
-
 func shouldPanic(f func()) {
        defer func() {
                if recover() == nil {