[swift-evolution] [Draft] Change @noreturn to unconstructible return type

Jeremy Pereira jeremy.j.pereira at googlemail.com
Tue Jun 7 09:36:01 CDT 2016


> On 6 Jun 2016, at 16:37, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
> 
> My opinion is based on this message:
> 
> On 05.06.2016 23:16, L. Mihalkovic via swift-evolution wrote:
> >
> > FWIW, in the rejection of SE-0097
> > <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160530/019879.html>,
> > this was what the core team had to say about it:
> >
> >     /1) For noreturn, the core team prefers to explore a solution where a
> >     function can be declared as returning an non-constructable “bottom”
> >     type (e.g. an enum with zero cases).  This would lead to something like:/
> >     /
> >     /
> >     /func abort() -> NoReturn { … }/
> 
> I.e. we need some type that will reflect "NoReturn" at first. Then, probably, it can be used as bottom type. IMO `Never` is the best candidate at this moment. For me it also can mean "never can have an instance of this type" or "never be created" or "never be user”


I disagree. We are discussing how to annotate a function in some way so that the compiler knows that the code following it will never be executed *and* so a human who reads the declaration knows that it does not return. “Never" is a poor choice for that. Never what? Never return? Never use this function? Never say never again? 

Call it NoReturn as the comment you quoted suggests. 

If you want bottom types for other uses, give them their own appropriate and self documenting names. 


More information about the swift-evolution mailing list