]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: Fix `internal compiler: getinarg: not a func` when returning invalid...
authoracanino <anthony.canino1@gmail.com>
Sat, 22 Aug 2015 02:24:20 +0000 (22:24 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 3 Oct 2015 15:32:46 +0000 (15:32 +0000)
commitacc90c53e8b5448afee8455ee7c4917af25c6bc9
treef3709eb509a1d7f30c68e022e184467e0115237f
parent788eb99b76d0817d238c3ad0952eb1fe6349f735
cmd/compile: Fix `internal compiler: getinarg: not a func` when returning invalid interface.

Internal error arose from calling methodfunc on a invalid interface
field during the implements check. int obviously isn't a function,
and errors on getinarg...

for im := iface.Type; im != nil; im = im.Down {
  imtype = methodfunc(im.Type, nil)
  // ...
}

Fix handles the internal compiler error, but does not throw an
additional error, i.e. the following code will error on the I
interface, but type A will pass the implements check since
'Read(string) string' is implemented and 'int' is skipped

type I interface {
  Read(string) string
  int
}

type A struct {
}

func (a *A) Read(s string) string {
  return s
}

func New() I {
  return new(A)
}

Fixes #10975

Change-Id: I4b54013afb2814db3f315515f0c742d8631ca500
Reviewed-on: https://go-review.googlesource.com/13747
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/subr.go
test/fixedbugs/issue10975.go [new file with mode: 0644]