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: usage of interface with type list not as type constraint shouldn't be allowed #41124
Comments
Seems like bug in the translation tool type Nat interface {
type Zero, Succ
}
type Zero struct{}
type Succ struct{ Nat } becomes type Zero struct{}
type Succ struct{ Nat }
type Importable୦ int where Nat is not defined. |
This shouldn't pass the type checker. You aren't allowed to embed an interface with a type list into a struct. An interface with a type list can only be used as a type constraint, not as a general type. So, yes, the translation tool mishandles it, but this code shouldn't get to the translation tool at all. |
var _ map[A]struct{}
var _ map[int]A
var _ []A
var _ chan A https://go2goplay.golang.org/p/TKaDmb6jrop |
Change https://golang.org/cl/251718 mentions this issue: |
Fixed on dev.go2go branch. |
…constraints Check that such constraint interfaces don't appear in: - composite types - type and function instantiations - assertions - type switches Streamlined respective error messages. Added lots of tests. Fixes #41124. Change-Id: Ie04a95ab056b40561484f04ed6e843ca371e1d41 Reviewed-on: https://go-review.googlesource.com/c/go/+/251718 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
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/fD4PjTJLgdz
What did you expect to see?
Successful compilation or better error message.
What did you see instead?
The text was updated successfully, but these errors were encountered: