-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: declaration order of types affects cycle detection #68025
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
Comments
I should note that while rearranging the code fixes the problem, if the definitions are in different files (which happens to be the case for my real code, since a bunch of different types are used in the interface definition, i.e. something more like: type A interface {
*B | *D | *E | *F | *G | *H
} then it sometimes fails and sometimes doesn't. I've yet to figure out exactly what is determining the order in that case. |
CC @griesemer |
Thanks for the report. Our cycle detection algorithm could use some love. |
Didn't get to this. For 1.25. |
This issue is currently labeled as early-in-cycle for Go 1.25. |
Came across this while looking at some other issues — here is another playground that also reproduces. |
Go version
go version go1.22.3 darwin/amd64
Output of
go env
in your module/workspace:What did you do?
I found that this will not compile: https://go.dev/play/p/X-_09aV9wYj
While just moving the declaration of the interface to after the struct definitions causes it to compile fine: https://go.dev/play/p/xic2fqhfmTi
What did you see happen?
What did you expect to see?
I expected both versions of the code to compile and run without error.
The text was updated successfully, but these errors were encountered: