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: provide better error message when saying that type parameter cannot be embedded in interface #39948
Comments
Note 1: It doesn't matter if you wrap the Note 2: I'm not 100% sure this is supposed to work, but I didn't see it excluded in the spec. Also if it's not supposed to work an error message that specifically says so would be good. |
The constraints on T and U don't restrict them to be interfaces just any type that satisfies the empty interface (which is all of them). I don't know if there is a way to do this. If there is I would have expected |
Yeah I just came to the same conclusion, reading the spec I think there is no way to constrain the type to only interface types? That seems like maybe a spec problem and not (only) an implementation problem. |
The type checking errors for the original program are:
That's correct. The type constraint for T is In the current design draft there is no way to write a type constraint that says that a type must be an interface type. Whether this is a real problem depends on why people would want to write that requirement. Closing because there is no issue. General discussion of the design draft should take place on golang-nuts, not on the issue tracker. Thanks. |
Changing the error message to "is not constrained to interface" or "is not only an interface" would give folks like me a big clue about the real problem. |
OK, reopening as a request for a better error message. |
Thanks! |
Change https://golang.org/cl/240520 mentions this issue: |
Fixed on dev.go2go. |
…meter with an interface Fixes #39948. Change-Id: I868d2264a674a92c39fbe31d89bc002dd74c26fe Reviewed-on: https://go-review.googlesource.com/c/go/+/240520 Reviewed-by: Robert Griesemer <gri@golang.org>
What version of Go are you using (
go version
)?dev.go2go @ 236ad5a
(latest as of a minute ago)
What did you do?
What did you expect to see?
I expected this to compile.
What did you see instead?
Type checking failed, errors on the indicated lines.
The text was updated successfully, but these errors were encountered: