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: improve error messages for missing or superfluous type constraints #43527
Comments
CC @griesemer |
The first error is fixed in the latest (internal, not deployed version). The 2nd error is correct but misleading: Since the type parameter list is Anyway, agreed that the error message should be better. |
A similar case occurs when defining generic types if you omit the constraint on the type parameter, e.g. That is, if you write
instead of
In the go2go playground, the error currently says "undeclared name: T", rather than "type parameter T is missing type constraint"
Ugh, I didn't realise that was allowed. If you want to discard arguments, you can also write |
"type slot[T] some_type" defines That said, we might want to tweak the compiler error message here to make clear that the type is being interpreted as an array type. |
1 similar comment
"type slot[T] some_type" defines That said, we might want to tweak the compiler error message here to make clear that the type is being interpreted as an array type. |
Change https://golang.org/cl/348730 mentions this issue: |
Change https://golang.org/cl/348731 mentions this issue: |
…nstraint For #43527. Change-Id: I8c706e68572286d5675383eb2dfd75b5618b646b Reviewed-on: https://go-review.googlesource.com/c/go/+/348730 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Change https://golang.org/cl/348742 mentions this issue: |
…lists When parsing a type parameter declaration, parts of the code still expected a ) as closing token. Use the correct follow token ) or ] depending on parameter list kind. Also, consistently use tokstring (not tok.String()) for user-facing (error) messages. Follow-up on comment in CL 348730. For #43527. Change-Id: Ib1d4feb526771a1668a54c3bb7a671f6c8a65940 Reviewed-on: https://go-review.googlesource.com/c/go/+/348742 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
What version of Go are you using (
go version
)?go2go playground
Does this issue reproduce with the latest release?
N/A
What operating system and processor architecture are you using (
go env
)?N/A
What did you do?
https://go2goplay.golang.org/p/m9YUDBTWwpA
https://go2goplay.golang.org/p/GDxiXiIIti7
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: