Similar to a couple other resolved issues, e.g. #346
redundantReturn is removing removing return from a catch let block
Before swiftformat:
do {
...
} catch let e as DecodingError {
return .failure(.decodingError(e))
} catch {
return .failure(.error(error))
}
After swiftformat:
do {
...
} catch let e as DecodingError {
.failure(.decodingError(e))
} catch {
return .failure(.error(error))
}
Using // swiftformat:disable:next redundantReturn for now as suggested in other issues :)
Thanks for your awesome work!
@ryanmeisters thanks for reporting this, I'll get it fixed asap.
@ryanmeisters I wasn't able to reproduce this with the information provided. I suspect it may depend on the surrounding code. Can you provide an isolated sample that demonstrates the issue?
Oh hmm. Sure thing. I'm able to reproduce with the following
func test() -> Int {
do {
let x = try JSONDecoder().decode(String.self, from: Data())
return 1
} catch let e as DecodingError {
return 1 // <-- swiftformat removes return here
} catch {
return 1
}
}
Just in case, here is my actual code
and here is my .swiftformat
I was being stupid and not setting the swift version to >=5.1 馃お I've got a solution now, and it'll be fixed in the next release. Thanks again 馃憤
@ryanmeisters fixed in 0.40.14.
Most helpful comment
@ryanmeisters thanks for reporting this, I'll get it fixed asap.