Fix a bug where an unfolded SequenceExpr
would make it to the pretty-printer.
#641
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.
Since the
UseExplicitNilCheckInConditions
rule was using string interpolation based parsing, it returned aSequenceExpr
instead of anInfixOperatorExpr
. This unfolded expression then made it to the pretty printer, which it didn't expect (because the input is folded before being processed by the rules, but not after that).In this case, creating the new expression directly as nodes is barely more work than using the string-based parsing and then folding it, so I just did that.
Tests didn't catch this because the sequence expr is valid Swift code when stringified (for comparison in unit tests). To address this, we now do a pretty-printer pass on all the format rule outputs. We don't assert based on the pretty-printed output (that's not really a "unit" test anymore), but it at least causes a test crash if the output wasn't suitable for pretty printing.
Doing so caught a similar latent bug in
UseShorthandTypeNames
.