swiftlang / swift-syntax

A set of Swift libraries for parsing, inspecting, generating, and transforming Swift source code.
Apache License 2.0
3.18k stars 403 forks source link

[SwiftParser] Handle extraneous case keyword after comma in switch case. #2665

Closed gregomni closed 3 months ago

gregomni commented 3 months ago

For errors of the form case .a, case .b: instead of the expected case .a, .b:, produce just a single initial unexpected token in the second SwitchCaseItemSyntax instead of a bad pattern and then a second separate full case.

See https://github.com/apple/swift/pull/74071, which is essentially the same change made to the old parser.

ahoppen commented 3 months ago

@swift-ci Please test

gregomni commented 3 months ago

Oops! That test didn't fail for me locally, but I see the problem.

ahoppen commented 3 months ago

@swift-ci Please test

ahoppen commented 3 months ago

By the way, the test didn’t fail locally for you because CI runs test case mutation which isn’t enabled by default. https://github.com/apple/swift-syntax/blob/main/CONTRIBUTING.md#test-case-mutation has a little more documentation about it.

ahoppen commented 3 months ago

@swift-ci Please test