Closed antiraum closed 10 months ago
Paging @calda
@calda do you think it's sufficient to remove the stray try
here (and maybe do the same for await
?) or would it be safer just to not remove the closure at all in this scenario?
@antiraum FYI I think it's actually the redundantClosure
rule that's a fault here.
Ah, yes, this looks like a bug in redundantClosure
. We'd need to either drop the proceeding try
before the closure call if present.
I did confirm both of these compile:
struct MyType {
static func throwing() throws -> MyType { MyType() }
}
var condition = true
let value1: MyType? = try if condition {
MyType.throwing()
} else {
nil
}
let value2: MyType? = if condition {
try MyType.throwing()
} else {
nil
}
print(value1)
print(value2)
The problem is just when you have try in both places.
I'll post a fix.
@calda cool, thanks for confirming - I'll take care of it.
Oh, sure, if you're planning on making the fix that's fine too. Thanks!
@antiraum fixed in 0.52.7
Thanks a lot!
Version 0.52.6 / Swift 5.9
conditionalAssignment
reformats the following codeto
Which doesn't seem to be allowed. The Xcode error message is