Swift 3’s “Never”
SE-0102 removes the rarely-used
@noreturn
function type and replaced it with a dead-end return type[…][…]
Never
allows a function or method tothrow
: e.g.() throws -> Never
. Throwing allows a secondary path for error remediation, even in functions that were not expected to return.As a first class type,
Never
works with generics in a way that the@noreturn
attribute could not.
Guard conditions require you to exit scope.
Never
mean you cannotreturn
from your function. So, instead, add a simpledo
-scope layer[…]
Fortunately, I don’t think this sort of contortion is commonly needed.