You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: bad error message when defining a variable for a parenthesized type #68589
changed the title [-]Bad error message when defining a variable for a parenthesized type[/-][+]cmd/compile: bad error message when defining a variable for a parenthesized type[/+]on Jul 25, 2024
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).
Activity
gabyhelp commentedon Jul 25, 2024
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
[-]Bad error message when defining a variable for a parenthesized type[/-][+]cmd/compile: bad error message when defining a variable for a parenthesized type[/+]ianlancetaylor commentedon Jul 25, 2024
CC @griesemer @golang/compiler
griesemer commentedon Jul 31, 2024
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).
gopherbot commentedon Oct 31, 2024
Change https://go.dev/cl/623819 mentions this issue:
cmd/compile: better error message when offending/missing token is a keywordcmd/compile: better error message when offending/missing token is a k…