-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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/compile: less helpful error message for invalid array types #51145
Comments
Thank you @Merovius for taking initiative. I hesitated about posting it myself, because I guess that problem error message "invalid array bound float64" was possible, when compiler know that "[something]" means definition of array. But now it can also mean definition of type parameter and compiler can't/doesn't decide which case it is. Of course, I may be wrong. |
This happens to be trivial to fix and it is not invasive. CL forthcoming. |
Change https://go.dev/cl/385255 mentions this issue: |
Change https://go.dev/cl/439476 mentions this issue: |
Change https://go.dev/cl/439559 mentions this issue: |
…nstraint If a generic type declaration is missing a constraint, syntactically it is an array type declaration with an undefined array length. Mention the possibility of a missing constraint in the error message for the undefined array length. For #56064. For #55961. For #51145. Change-Id: Ic161aeda9ea44faa8aa3bf3e9d62b3b13a95d4c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/439559 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
…nstraint If a generic type declaration is missing a constraint, syntactically it is an array type declaration with an undefined array length. Mention the possibility of a missing constraint in the error message for the undefined array length. For golang#56064. For golang#55961. For golang#51145. Change-Id: Ic161aeda9ea44faa8aa3bf3e9d62b3b13a95d4c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/439559 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Originally reported on golang-nuts.
It seems the go 1.18 type checker provides less helpful error messages in some cases of invalid array type declarations. For this declaration:
The go 1.17 compiler prints (playground link):
While the go 1.18 compiler prints (playground link):
Note that it omits the "invalid array bound float64" message. This seems like a regression to me.
The text was updated successfully, but these errors were encountered: