cmd/compile: parser rejects unambiguous unparenthesized TypeName composite literals in Condition expression of ForClause #48159
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone
This package is rejected as syntactically invalid by go/parser and cmd/compile (and Go 1.4's 6g), but accepted by gccgo:
The Go spec says [emphasis added]:
I think the intention here is that this is a gccgo parser issue for allowing TypeName composite literal between
for
and{
without enclosing it in parentheses.However, arguably this case isn't actually ambiguous: we've seen one semicolon after the
for
keyword, so we know to expect another;
before the{
. And so the emphasized sentence technically doesn't apply as there's no ambiguity to resolve, and the program should be accepted./cc @griesemer @ianlancetaylor
The text was updated successfully, but these errors were encountered: