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/go2go: endless recursion on recursive type constraints #39781
Comments
This issue seems similar to issue #39680 but more complex. |
This is an infinite loop in the type checker. It should probably return an error. |
Hi @griesemer @ianlancetaylor. So, I think I found a way to fix it func optype(typ Type) Type {
if t := typ.TypeParam(); t != nil {
// If the optype is typ, return the top type as we have
// no information. It also prevents infinite recursion
// via the TypeParam converter methods. This can happen
// for a type parameter list of the form:
// (type T interface { type T }).
// See also issue #39680.
if u := t.Bound().allTypes; u != nil && u != typ {
if t2 := u.TypeParam(); t2 != nil && t2.Bound().allTypes == typ {
return theTop
}
// u != typ and u is a type parameter => u.Under() != typ, so this is ok
return u.Under()
}
return theTop
}
return typ
} |
Change https://golang.org/cl/248357 mentions this issue: |
Go 1.18 doesn't allow to embed type parameters (adjusted example). This reports now a proper error. Closing. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
reproduces with 2faeebf
playground doesn't crash
What operating system and processor architecture are you using (
go env
)?n/a
What did you do?
https://go2goplay.golang.org/p/G9DePoefrx0
What did you expect to see?
Successful compilation
What did you see instead?
Partial stack trace:
The text was updated successfully, but these errors were encountered: