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: method definitions based on later-defined methods don't compile (pathological) #7495

Closed
griesemer opened this issue Mar 8, 2014 · 2 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

http://play.golang.org/p/WMpE0q2wK8

produces:

prog.go:7: T.m2 undefined (type T has no method m2)
prog.go:7: invalid expression unsafe.Sizeof(T.m2)
 [process exited with non-zero status]

But switching m1 and m2 works:

http://play.golang.org/p/uR3wFJcAHq

In general, ordering declarations differently won't work:

http://play.golang.org/p/iAV8x86giC

These are clearly pathological cases but point out some limitations of gc's type checker.

gccgo handles these cases w/o problem.
go/types has the same problem.
@bradfitz bradfitz removed the new label Dec 18, 2014
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gc: method definitions based on later-defined methods don't compile (pathological) cmd/compile: method definitions based on later-defined methods don't compile (pathological) Jun 8, 2015
@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 26, 2016
@ericlagergren
Copy link
Contributor

As of Go 1.21, the first example currently compiles. The third exits with

./prog.go:8:28: illegal cycle in method declaration

@griesemer
Copy link
Contributor Author

Thanks for reviving this.

The 3rd example is expected to fail as the type checker is (currently) not intended to work with cycles where partial information (such as function size independent of the actual function signature).

So this is not all working as intended.
Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants