[swift-evolution] [Draft] Change @noreturn to unconstructible return type
brent at architechies.com
Mon Jun 6 03:27:18 CDT 2016
> Bringing up an old idea, we could rewrite `rethrows` using Never and throws type specification:
> func call<T, E>(block: () throws E -> T) throws E -> T
> But this requires some compiler magic: non-throwing functions should effectively become functions throwing Never.
This is very clever, and a very natural way to design things *if* Never is a proper bottom type, instead of just an empty enum. I don't even think you can really describe this as "compiler magic": Just as a function with no return type implicitly returns Void, so a function with no throw type implicitly throws Never.
(Incidentally, the `E` should be `E: ErrorProtocol`, I believe, since you can only throw ErrorProtocols. That's why Never needs to be a proper bottom type: it needs to conform to `ErrorProtocol`.)
More information about the swift-evolution