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: false positive error about recursive type aliases #23055

mdempsky opened this issue Dec 8, 2017 · 4 comments


None yet
4 participants
Copy link

commented Dec 8, 2017

cmd/compile erroneously emits an "invalid recursive type alias" error for:

package p

type a struct { b }
type b = c
type c struct { *b }

Related: #18640

@mdempsky mdempsky added this to the Go1.11 milestone Dec 8, 2017

@rasky rasky added the NeedsFix label Dec 8, 2017


This comment has been minimized.

Copy link

commented Dec 10, 2017

Hi, i want to take this issue.


This comment has been minimized.

Copy link
Member Author

commented Dec 11, 2017

@JicLotus Thanks for volunteering. If you'd like to work on this, feel free. I do want to caution though that this is likely to be a fairly subtle and involved part of the compiler.

The problem is that we recursively evaluate type declarations as needed. I think we'll need to undo this and instead evaluate type declarations in a two pass algorithm:

  1. Set up a TFORW type for each package-scoped declared type and associate the Sym with that type.
  2. Resolve each type declaration and assign the TFORW type's underlying type.

I'm suspecting we'll also have to split constant evaluation into a separate pass too. I briefly touched on this idea in #13890 (comment). But it might be possible to fix this issue without doing that.


This comment has been minimized.

Copy link

commented Dec 11, 2017

Great @mdempsky


This comment has been minimized.

Copy link

commented May 31, 2018

I'm going to close this one as it is fundamentally a duplicate of #18640 (which has been reopened); see here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.