Swiftformat: Possible bug in spaceAroundOperators

Created on 4 Sep 2020  路  3Comments  路  Source: nicklockwood/SwiftFormat

My test example:

func myFunc() -> [UIColor] {
    return [ .red ]
}

The command I ran:
$ swiftformat test.swift --rules spaceAroundOperators

I expected the code to remain unchanged. However, it updates to the following:

func myFunc() -> [UIColor] {
    return [.red ]
}

It appears to be treating the [ as an operand.

bug fixed in develop

All 3 comments

@meherkasam thanks for reporting, I think the bug is actually that it always tries to remove the space between an opening bracket and a prefix ., but either way it needs fixing.

Thank you for the quick response!

@meherkasam fixed in 0.46.2.

Was this page helpful?
0 / 5 - 0 ratings