swift-syntax
swift-syntax copied to clipboard
Improve diagnostic for unnamed closure parameter
Issue Kind
Bad Diagnostic Produced
Source Code
test { ([X]) in }
Description
New parser:
error: unexpected code '[X]' in parameter clause
test { ([X]) in }
^~~
Old parser:
warning: unnamed parameters must be written with the empty name '_' [parameter_unnamed_warn]
test { ([X]) in }
^
_:
This is a special case. More generally, the old parser is capable of diagnosing this kind of closure parameter production gracefully when all of the following are true:
- An argument name cannot be parsed (link)
- A type can be parsed per
Parser::canParseType()
, and said type is followed by,
,)
, or=
(link)
Related to #2331.
Tracked in Apple’s issue tracker as rdar://118109912
Could I be assigned the issue? Thanks!
To clarify: The C++ parser used to emit a warning for this and is changed in https://github.com/apple/swift/pull/70065 to instead emit an error. The new parser should also emit an error but one that is nicer than the currently emitted unexpected code '[X]' in parameter clause