Autocorrect for "colon" corrupts file when preprocessor macros are present #2099
Closed
2 tasks done
Labels
bug
Unexpected and reproducible misbehavior.
New Issue Checklist
Bug Report
Complete output when running SwiftLint, including the stack trace and command used
Environment
swiftlint version
to be sure)? 0.25.0 does not find anything to autocorrect (due to "colon" violation no longer autocorrected in dictionary literals (since 0.23.1) #2050), however anything after dddb0f6 shows the issuexcode-select -p
)? 9.2Steps to Reproduce
Source File
Run
autocorrect
Corrected File
The duplicate correction ends up truncating the dictionary such that it doesn't compile. The amount of truncation is always equal to the number of extra spaces between the end of the key and the colon.
Variations Attempted
The issue is only reproducible with a dictionary literal, replacing the 4th line with
or
works as expected.
Removing the preprocessor macros entirely also fixes the issue, but this isn't possible in the real world case that uncovered this bug.
As best I can tell SourceKitten is getting confused by the preprocessor macros but only in the dictionary literal case. Examining
file.structure
inColonRule.correctionRanges(in:)
shows two identical entries, which causes swiftlint to emit two corrections at the same location.structure output
The text was updated successfully, but these errors were encountered: