-
Notifications
You must be signed in to change notification settings - Fork 18.1k
cmd/go2go: type checking for generic constraints doesn't work correctly #39754
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
Comments
But
fails with
|
Another example crashes on 0a03088 and runs on playground. Partial stack trace:
|
Looks like the type checker fails to report an error. Smaller test case: package main
type Optional(type T) struct {
p T
set bool
}
func (o Optional(T)) Val() (T, bool) {
return o.p, true
}
type Box(type T) interface {
Val() (T, bool)
}
func F1(type V interface{}, A, B Box(V))() {}
func main() {
F1(int, Optional(int), Optional(string))()
} This requires that both |
@mmaedel I'm not sure what problem you are running into, but it's a different problem. Please open a separate issue. Thanks. |
https://go2goplay.golang.org/p/jmaTevSNW0X UPD. func optype(typ Type) Type { // typ is I generic
if t := typ.TypeParam(); t != nil { // I is a type param
if u := t.Bound().allTypes; u != nil && u != typ { // t bound only by method list, not by type list, so allTypes is nil
return u.Under()
}
return theTop // here function returns
}
return typ
}
|
…ere’s more than one generic constraint. Fixes golang#39754.
Change https://golang.org/cl/240339 mentions this issue: |
…ere’s more than one generic constraint. Check of first constraint was breaking the loop, so other constraints was skipped Fixes #39754. Change-Id: I48caa380472371a438c2d2029d1383d03dbf22df GitHub-Last-Rev: bf418db GitHub-Pull-Request: #39902 Reviewed-on: https://go-review.googlesource.com/c/go/+/240339 Reviewed-by: Robert Griesemer <[email protected]>
Seems to be fixed. Closing. |
Change https://golang.org/cl/240478 mentions this issue: |
While at it, simplified test case a bit. Fixes #39935. Updates #39754. Change-Id: Ia3b51f23807d25e62113757c51a660c7e3a9b381 Reviewed-on: https://go-review.googlesource.com/c/go/+/240478 Reviewed-by: Robert Griesemer <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
n/a
What operating system and processor architecture are you using (
go env
)?What did you do?
https://go2goplay.golang.org/p/QLrCSQoyvVb
What did you expect to see?
go2go's typechecker error for line 57.
What did you see instead?
Successful compilation.
The text was updated successfully, but these errors were encountered: