Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

gregomni
Copy link

@gregomni gregomni commented Jun 1, 2024

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 swiftlang/swift#74071, which is essentially the same change made to the old parser.

@gregomni gregomni requested review from ahoppen and bnbarham as code owners June 1, 2024 23:26
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great!

@ahoppen
Copy link
Member

ahoppen commented Jun 2, 2024

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge June 2, 2024 05:54
auto-merge was automatically disabled June 2, 2024 14:06

Head branch was pushed to by a user without write access

@gregomni
Copy link
Author

gregomni commented Jun 2, 2024

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

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix. Could you also squash your commits? We generally prefer that (https://github.com/apple/swift-syntax/blob/main/CONTRIBUTING.md#authoring-commits)

arena: self.arena
)
} else {
unexpectedPrePatternCase = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change indentation to 2 spaces by running swift-format (https://github.com/apple/swift-syntax/blob/main/CONTRIBUTING.md#formatting)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Sorry about the sloppiness.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a problem at all.

@ahoppen
Copy link
Member

ahoppen commented Jun 3, 2024

@swift-ci Please test

@ahoppen
Copy link
Member

ahoppen commented Jun 3, 2024

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
Copy link
Member

ahoppen commented Jun 4, 2024

@swift-ci Please test

@ahoppen ahoppen merged commit 371ea75 into swiftlang:main Jun 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants