-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Trailing comma implementation #71975
Trailing comma implementation #71975
Conversation
A heads up that the full implementation will require changes to the Swift parser in swift-syntax. |
Sorry, I should have linked the swift-syntax PR |
@CodaFi I've updated the implementation for conditionals to use a much simpler lookahead approach |
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.
I have reviewed and left comments suggesting a few small changes.
@CodaFi could you take another look here? The implementation is up to date with the one approved in swiftlang/swift-syntax#2515 Thanks! |
func testConditionsWithTrailingComma() { | ||
func f(_ block: (Bool) -> Bool) -> Bool { block(true) } | ||
|
||
if true, { } |
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.
What about cases such as if true { let a = 1 }
how would those be handled? Looking through isStartOfConditionalStmtBody
method, I couldn't see if those would be handled or not.
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.
It parses fine because skipSingle()
jumps from {
to }
and then there's nothing after that rules out { let a = 1 }
as the if body.
Co-authored-by: Luciano Almeida <passos.luciano@outlook.com>
The swift-syntax implementation (swiftlang/swift-syntax#2515) has been merged. |
This is a prototype implementation for Allow trailing comma in tuples, arguments and if/guard/while conditions gated behind
-enable-experimental-feature TrailingComma
.