I realized I was unclear: "Last expression as return value" doesn't solve this problem, like a keyword does. I read through the original pitch, today. It's missing a do/catch example where multiple scope exits are necessary. I think it would have been more popular with a good one included.
The following is not a good one, but has the form of what needs to be addressed.
Current compiling Swift:
let foo = try {
do {
return try bar()
} catch {
guard fallbackCondition else {
print("this is unexpected, investigate this")
return "Error \(error)"
}
return switch value {
case 0x80..<0x0800: "No a problem"
default: try {
print("Ultra broken! \(error)")
throw error
} ()
}
}
} ()
Better, even if guard doesn't work like it should :
let foo = try do {
try bar()
} catch {
if !fallbackCondition {
print("this is unexpected, investigate this")
break "Error \(error)"
}
break switch value {
case 0x80..<0x0800: "Not a problem"
default:
print("Ultra broken! \(error)")
throw error
}
}