Skip to content

[6.0] Default to not requiring whitespace before ( #2595

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

ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 10, 2024

  • Explanation: There are only a few cases where ( should be preceded by a space: closure parameters, function types and tuples. Instead of defaulting to add whitespace before (, check for those cases and if we are not in one of them, don’t require whitespace. This has become important since we diagnose a space between an attribute name an it’s opening ( as a warning in Swift 5 and as an error in Swift 6 mode.
  • Scope: Running BasicFormat on source code that contains a non-keyword token followed by (.
  • Risk: I don’t see any case where not emitting a space in front of ( could break something apart from the cases that we have covered. And without this fix, a lot of code generated by macros does not compile in Swift 6 mode.
  • Testing: Added tests
  • Issue: rdar://124569733
  • Reviewer: @bnbarham on Default to not requiring whitespace before ( #2592

There are only a few cases where `(` should be preceded by a space: closure parameters, function types and tuples.

Instead of defaulting to add whitespace before `(`, check for those cases and if we are not in one of them, don’t require whitespace.

rdar://124569733
@ahoppen ahoppen requested a review from bnbarham as a code owner April 10, 2024 19:48
@ahoppen
Copy link
Member Author

ahoppen commented Apr 10, 2024

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Apr 10, 2024

swiftlang/swift#72960

@swift-ci Please test

@ahoppen ahoppen disabled auto-merge April 10, 2024 20:15
ahoppen added a commit to ahoppen/swift that referenced this pull request Apr 11, 2024
@ahoppen
Copy link
Member Author

ahoppen commented Apr 11, 2024

swiftlang/swift#72960

@swift-ci Please test

@ahoppen ahoppen merged commit 302cd7c into swiftlang:release/6.0 Apr 11, 2024
@ahoppen ahoppen deleted the ahoppen/6.0/no-space-before-attribute-paren branch April 11, 2024 17:29
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