Skip to content

Improve diagnostic for unnamed closure parameter #2340

@AnthonyLatsis

Description

@AnthonyLatsis

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.

Metadata

Metadata

Assignees

Labels

SwiftParserBugs in the (new) Parser written in SwiftbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions