For me, the bigger issue is that we're not applying the same strict judgement to rethrows
that we do to the typed throws equivalent. For example, it's fairly trivial to 'break-out' of the intended semantics of rethrows
, too:
struct MyError: Error {}
func f(_ a: () throws -> Void) rethrows {
func g(_ b: () throws -> Void) throws {
throw MyError()
}
try g(a)
}
In this example, the supplied closure, a
, is never called yet MyError
is thrown. This clearly breaks the intended semantics of 'f should throw if and only if a throws'.
EDIT: To be fair, this method does trigger a runtime exception when called with a non-throwing function.