[swift-evolution] Type-annotated throws

Joe Groff jgroff at apple.com
Mon Aug 29 11:24:13 CDT 2016

> On Aug 26, 2016, at 8:39 AM, FĂ©lix Cloutier via swift-evolution <swift-evolution at swift.org> wrote:
> Hi all,
> Currently, a function that throws is assumed to throw anything. There was a proposal draft last December to restrict that. The general idea was that you'd write, for instance:
>> enum Foo: ErrorProtocol {
>>     case bar
>>     case baz
>> }
>> func frob() throws Foo {
>>     throw Foo.bar // throw .bar?
>> }
> If you `catch Foo` (or every case of Foo), now that the compiler can verify that your catch is exhaustive, you no longer have to have a catch-all block at the end of the sequence.
> This impacts the metadata format and has implications on resilience, which leads me to believe that the discussion could qualify for the phase 1 of Swift 4. If this is the case, I'd be interested in pulling out the old discussions and seeing where we left that at.

Typed throws is largely additive, since an API that `throws` today can be compatibly changed to `throws T` in the future, so this isn't an absolute ABI issue.


More information about the swift-evolution mailing list