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

Closed
mdempsky opened this issue Dec 8, 2017 · 4 comments
Closed

cmd/compile: false positive error about recursive type aliases #23055

mdempsky opened this issue Dec 8, 2017 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

mdempsky 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 The path to resolution is known, but the work has not been done. label Dec 8, 2017
@JicLotus
Copy link

Hi, i want to take this issue.

@mdempsky
Copy link
Member Author

mdempsky 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.

@JicLotus
Copy link

Great @mdempsky

@griesemer
Copy link
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants