mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
788eb99b76
commit
acc90c53e8
2 changed files with 22 additions and 0 deletions
|
|
@ -2986,6 +2986,9 @@ func implements(t *Type, iface *Type, m **Type, samename **Type, ptr *int) bool
|
|||
var followptr bool
|
||||
var rcvr *Type
|
||||
for im := iface.Type; im != nil; im = im.Down {
|
||||
if im.Broke == 1 {
|
||||
continue
|
||||
}
|
||||
imtype = methodfunc(im.Type, nil)
|
||||
tm = ifacelookdot(im.Sym, t, &followptr, 0)
|
||||
if tm == nil || tm.Nointerface || !Eqtype(methodfunc(tm.Type, nil), imtype) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue