Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: internal compiler error: getinarg: not a func when returning invalid interface #10975

Closed
dominikh opened this issue May 28, 2015 · 2 comments
Milestone

Comments

@dominikh
Copy link
Member

Input:

package bug

type I interface {
    int
}

func New() I {
    return struct{}{}
}

Output:

dominikh-pc /tmp $ go build foo.go
# command-line-arguments
./foo.go:4: interface contains embedded non-interface int
./foo.go:8: internal compiler error: getinarg: not a func int

Expected output:
No internal compiler error.

Version:
go version devel +5ee5528 Thu May 28 12:04:35 2015 +0000 linux/amd64

Also happens with Go 1.4.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone May 28, 2015
@anthonycanino1
Copy link
Contributor

I spent some time narrowing down why this bug happens and would like to provide a fix with some guidance (would by my first contribution).

I believe the issue is in the subr.go:implements function. The bad embedded type 'int' is flagged as broke in dcl.go:interfacefield but is still checked to see if it is implemented in the code below. int obviously isn't a method, which eventually errors in methodfunc/getinarg.

for im := iface.Type; im != nil; im = im.Down {
  imtype = methodfunc(im.Type, nil)
  tm = ifacelookdot(im.Sym, t, &followptr, 0)

A "fix" is to skip over the check if im.Broke == 1, but I am not sure if that is correct. Any advice on the desired way to handle this?

@gopherbot
Copy link

CL https://golang.org/cl/13747 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants