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

Open
findleyr opened this issue Apr 13, 2021 · 0 comments
Assignees
Milestone

Comments

@findleyr
Copy link
Contributor

@findleyr findleyr commented Apr 13, 2021

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 modified the milestones: Go1.17, Go1.18 Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants