[swift-evolution] [Review] SE-0102: Remove <at> noreturn attribute and introduce an empty NoReturn type

Anton Zhilin antonyzhilin at gmail.com
Wed Jun 22 08:26:30 CDT 2016

Pyry Jahkola via swift-evolution <swift-evolution at ...> writes:

> On 22 Jun 2016, at 14:47, Charlie Monroe via swift-evolution <swift-
evolution-m3FHrko0VLzYtjvyW6yDsg at public.gmane.org> wrote:
> I can live with Never. But the proposed NoReturn is a single-case 
solution and would eventually require a code-breaking change anyway were 
the bottom type implemented under a different name.
> Excuse me, but it seems to me you might be missing one important point 
about the proposal: there's going to be no “the” bottom type — any enum 
with no cases would act as one if the proposal is accepted. The standard 
library would just happen name one to stand as the preferred default.
> In other words (unless I'm mistaken), no compiler magic proposed about 
a specific (`NoReturn` or `Never`) empty enum. All the proposed “magic” 
would be about uninhabited types (link to specific section in the 
proposal) as return types.
> — Pyry

I think a good design would still be to use a single "main" empty type 
throughout the standard library.
Let's look at a silly example:

func swapReturnThrow<T, E>(block: () throws E -> T) throws T -> E where 
T: ErrorType, E: ErrorType

If T is NoReturn or E is NoThrow then swapReturnThrow would return 
NoThrow and throw NoReturn. These scoped empty types were pulled to a 
scope where they make no sense.

This problem does not occur with a single "main" empty type. But then we 
must decide on its name now.

More information about the swift-evolution mailing list