Skip to content

[5.9] Add diagnostic for array type #1573

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

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented Apr 23, 2023

  • Explanation: When having a type with a right square bracket we didn't suggest to add a left square bracket. This PR will improve the error message and add a fix-it
  • Scope: Swift parser and diagnostics
  • Risk: Low
  • Testing: Added correct test cases
  • Issue: N/A
  • Reviewer: @ahoppen on Add diagnostic for array type #1449

@kimdv kimdv requested a review from ahoppen as a code owner April 23, 2023 08:50
@kimdv kimdv changed the title [5.9]https://github.com/apple/swift-syntax/pull/1449 [5.9] Add diagnostic for array type Apr 23, 2023
@kimdv kimdv requested a review from bnbarham April 23, 2023 08:51
@kimdv
Copy link
Contributor Author

kimdv commented Apr 23, 2023

@swift-ci please test

…-wrong-type

Add diagnostic for array type
@kimdv kimdv force-pushed the kimdv/cherry-pick-add-diagnostic-for-wrong-type branch from bb21fec to 3fd77d6 Compare May 22, 2023 07:41
@kimdv
Copy link
Contributor Author

kimdv commented May 22, 2023

@swift-ci please test

Comment on lines +1073 to +1074
if self.at(.rightSquareBracket) {
let (unexpectedBeforeRSquareBracket, rightSquareBracket) = self.expect(.rightSquareBracket)
Copy link
Member

Choose a reason for hiding this comment

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

Actually looking at this code again, I think we should only do this recovery if the ] is not on a new line. And I also realized that we could write this as follows. If you could incorporate those changes in main, that would be great.

Suggested change
if self.at(.rightSquareBracket) {
let (unexpectedBeforeRSquareBracket, rightSquareBracket) = self.expect(.rightSquareBracket)
if let rightSquareBracket = self.consume(if: .rightSquareBracket) {

And since I just found another thing to comment on and this PR only provide value in a very niche use case, I’d prefer not to cherry-pick it to 5.9.

@ahoppen ahoppen closed this May 22, 2023
@kimdv kimdv deleted the kimdv/cherry-pick-add-diagnostic-for-wrong-type branch May 23, 2023 04:08
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