Open iwahbe opened 1 month ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
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).
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: