Skip to content

Commit

Permalink
cmd/gc: blank methods are not permitted in interface types
Browse files Browse the repository at this point in the history
Fixes #6606.

LGTM=rsc
R=rsc
CC=golang-codereviews, gri
https://golang.org/cl/156210044
  • Loading branch information
Chris Manghane committed Oct 15, 2014
1 parent 42c3130 commit db4dad7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/cmd/gc/dcl.c
Expand Up @@ -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++;
Expand Down
4 changes: 2 additions & 2 deletions test/interface/explicit.go
Expand Up @@ -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{}
Expand Down
14 changes: 0 additions & 14 deletions test/interface/fail.go
Expand Up @@ -14,7 +14,6 @@ type I interface {

func main() {
shouldPanic(p1)
shouldPanic(p2)
}

func p1() {
Expand All @@ -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 {
Expand Down

0 comments on commit db4dad7

Please sign in to comment.