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 with self-referential method in interface #6638

Open
griesemer opened this issue Oct 21, 2013 · 7 comments
Milestone

Comments

@griesemer
Copy link
Contributor

$ cat x.go
package p

import "unsafe"

type T interface {
    m() [unsafe.Sizeof(T(nil).m())]int
}


$ go tool 6g x.go
x.go:6: internal compiler error: getinarg: not a func E-36 <<S>> <T>
@griesemer
Copy link
Contributor Author

Comment 1:

Here's a simpler program producing the same error:
package p
type T interface {
    m() [T(nil).m()[0]]int
}

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 2:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 3:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 4:

Labels changed: added repo-main.

@griesemer
Copy link
Contributor Author

Comment 5:

Related, but of simpler form:
http://play.golang.org/p/peQWvRySw8
prog.go:6: type T has no method T.m
prog.go:6: invalid expression unsafe.Sizeof(T.m)
 [process exited with non-zero status]
(This package is accepted by gccgo and go/types).

@rsc rsc removed the compiler-bug label Apr 10, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: internal compiler error with self-referential method in interface cmd/compile: internal compiler error with self-referential method in interface Jun 8, 2015
@odeke-em
Copy link
Member

@griesemer some good news and some bad news

Your original program in #6638 (comment) now gives an error

$ go tool compile x.go 
x.go:6:25: cannot convert nil to type T

However, the problems seems to still exist.

@gopherbot
Copy link

Change https://golang.org/cl/139422 mentions this issue: go/types: determine hasPtrRecv property from source rather than type

gopherbot pushed a commit that referenced this issue Oct 4, 2018
LookupFieldOrMethod needs to know if a method receiver is a pointer
type. Until now this was computed from the the method signature's
receiver, which required the method signature to be type-checked.
Furthermore, it required the receiver to be set before the method
signature was fully type-checked in some cases (see issue #6638).

This CL remembers this property during object resolution, when we
know it from the source.

With this CL, method signatures don't need to be type-checked before
they can be looked up; this is a first step towards separating
type checking of types and type-checking of associated methods.

Updates #23203.
Updates #26854.

Change-Id: Ie3eb7976e8fe8176ea1b284fa7471a4b7000f80b
Reviewed-on: https://go-review.googlesource.com/c/139422
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants