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

go/types, cmd/compile/internal/types2: stack overflow checking recursive generic type #45550

Closed
findleyr opened this issue Apr 13, 2021 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@findleyr
Copy link
Contributor

The type checker does not currently handle invalid recursive constraints very gracefully. Consider the following

type Builder[T interface{ type struct{ Builder[T] } }] struct {}
type myBuilder struct { Builder[myBuilder] }

https://go2goplay.golang.org/p/HRHfhFsortG

If the declaration for myBuilder is commented out, we get an error that Builder is not a generic type. If it is uncommented, we get a stack overflow in subst.

We should instead emit an error that this recursive type declaration is invalid.

CC @griesemer

@griesemer griesemer self-assigned this Apr 13, 2021
@griesemer griesemer added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 13, 2021
@griesemer griesemer modified the milestones: Go1.17, Go1.18 Apr 13, 2021
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/348090 mentions this issue: cmd/compile/internal/types2: handle recursive type parameter constraints

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants