nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.9k stars 639 forks source link

RedundantParens: Format breaks compile for PAT optionals #1156

Closed CrownedPhoenix closed 2 years ago

CrownedPhoenix commented 2 years ago

Swift recently introduced the any keyword enabling Protocols-as-Types. The following code snippet, will compile:

protocol Thing {}

struct Barbarian {
    let weapon: (any Thing)?
}

But when run with .swiftformat --rules redundantParents . formats to the following (which does not compile):

protocol Thing {}

struct Barbarian {
    let weapon: any Thing?
}
nicklockwood commented 2 years ago

Sorry, I should've been more on-the-ball with this one. I'll get a fix out ASAP.

CrownedPhoenix commented 2 years ago

Honestly, I feel like you get a lot of points just for responding to this in like an hour. Thanks!

nicklockwood commented 2 years ago

@CrownedPhoenix fixed in 0.49.6