I've applied SwiftFormat to my Pods directory by accident. To my surprise this caused some code in it to break. One concrete example I've found is that this
guard case .some(Optional<Any>.some(let value)) = fieldValue else {
when reformatted to this
guard case let .some(Optional<Any>.some(value)) = fieldValue else {
stops compiling with '>' is not a postfix unary operator. This looks like a bug in Swift's toolchain parser to me, but until that's fixed it's probably best for SwiftFormat to work around that.
@MaxDesiatov thanks for reporting this. That's a weird one.
I've run into a little bit simpler case:
enum IntOrString {
case int(Int)
case string(String)
}
let value = IntOrString.string("Test")
guard case IntOrString
.string(let innerValue) else { // it might be a common format when the type name is long and enum case has multiple associated values
return
}
is formatted to:
guard case IntOrString
let .string(innerValue) = value else {
return
}
and breaks the code. I used 0.47.1 version.
@marciniwanicki this is a different issue, and should be easier to fix.
Thanks @nicklockwood, do you mind if I create a new ticket for it?
https://github.com/nicklockwood/SwiftFormat/issues/786 for the case I mentioned earlier. Let me know if I can help with anything.
@MaxDesiatov fixed in 0.47.2
Great, thanks a lot!