Trailing comma implementation#71975
Trailing comma implementation#71975mateusrodriguesxyz wants to merge 11 commits intoswiftlang:mainfrom
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 |
jameesbrown
left a comment
There was a problem hiding this comment.
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.
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.
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.