SE-0413: Typed throws

A do without a catch doesn't introduce a new context in which the errors can be caught, so the body is still treated as being part of the enclosing context.

Yes, that is correct. The key consideration here is that the body of the do..catch statement in which the throws clause is relevant is what's in the {...} immediately following the do. The bodies of catch clauses are in the throwing context of whatever the do...catch is embedded in, which is the function itself in all of your examples.

Yes. throws-clause is defined as:

throws-clause -> throws thrown-type(opt)

so do throws is permitted.

This force-boxes the error thrown from the do body to any Error. throws is equivalent to throws(any Error) in other contexts, and that should remain true here.

Yes, you are correct. That extension Error where Self == E did, in fact, make my life more difficult. I'll be turning that into a compiler test case...

(5) throws E.e, (6) throws F.e.

(7) throws E.e via your evil extension, (8) throws F.e.

(9) throws E.e via your evil extension, (10) throws F.e.

(11) throws E.e via your evil extension, (12) throws F.e.

Doug

7 Likes