-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: bad error message when defining a variable for a parenthesized type #68589
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
CC @griesemer @golang/compiler |
This is rather unusual code not typically encountered once a basic familiarity with Go has been established (at least that's the first time something like this has come to our attention in 15 years). It's also non-trivial to recognize that the parenthesized code is a type declaration in order to provide the desired error message; the effort doesn't seem justified given that this is just a rare situation. It perhaps makes sense to report something like "unexpected keyword type, expected type expression" to distinguish the two kinds of types. That would only incur a cost in case of an error (rare). |
Change https://go.dev/cl/623819 mentions this issue: |
Go version
go version go1.22.4 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I tried to compile this code (link):
What did you see happen?
The compilation errors with:
I wasn't sure if the above was valid Go code, but the compiler should give a better error message.
What did you expect to see?
An improved error message like:
The text was updated successfully, but these errors were encountered: