-
Notifications
You must be signed in to change notification settings - Fork 665
Update trailingCommas rule to support bug fixes in Swift 6.2
#2211
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
calda
commented
Sep 20, 2025
Comment on lines
+2421
to
+2452
| func testTrailingCommasNotAddedToTupleTypeInGenericBracketsInSwift6_2() { | ||
| // In Swift 6.2, trailing commas are unexpectedly not supported in tuple types | ||
| // within generic arguments: https://github.com/swiftlang/swift-syntax/pull/3153 | ||
| let input = """ | ||
| let foo: Array<( | ||
| bar: String, | ||
| quux: String | ||
| )> | ||
| """ | ||
|
|
||
| let options = FormatOptions(trailingCommas: .always, swiftVersion: "6.2") | ||
| testFormatting(for: input, rule: .trailingCommas, options: options, exclude: [.typeSugar, .propertyTypes]) | ||
| } | ||
|
|
||
| func testTrailingCommasAddedToTupleTypeInGenericBracketsInSwift6_3() { | ||
| let input = """ | ||
| let foo: Array<( | ||
| bar: String, | ||
| quux: String | ||
| )> | ||
| """ | ||
|
|
||
| let output = """ | ||
| let foo: Array<( | ||
| bar: String, | ||
| quux: String, | ||
| )> | ||
| """ | ||
|
|
||
| let options = FormatOptions(trailingCommas: .always, swiftVersion: "6.3") | ||
| testFormatting(for: input, output, rule: .trailingCommas, options: options, exclude: [.typeSugar, .propertyTypes]) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2211 +/- ##
========================================
Coverage 95.36% 95.37%
========================================
Files 155 155
Lines 29971 30033 +62
========================================
+ Hits 28582 28644 +62
Misses 1389 1389 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Swift 6.1 had bugs that unexpectedly disallowed trailing commas in a few places, like tuple values and generic argument lists (swiftlang/swift#81612).
This PR updates the
trailingCommasrule to add trailing commas in these places with using Swift 6.2.I found a remaining edge case in Swift 6.2 where trailing commas are still not supported in tuple values within generic argument lists. Working on landing a fix for that in Swift 6.3: swiftlang/swift-syntax#3153.
I'll release a new SwiftFormat version including this change after verifying that the Airbnb codebase compiles properly in Swift 6.2 after applying the updated
trailingCommasfunctionality.