@owenv created a post a while ago to discuss making Never
a bottom type.
In the meantime, you can get the same effect if you do something like this:
func ??<T>(lhs: @autoclosure () -> T?, rhs: @autoclosure () -> Never) -> T {
guard let _lhs = lhs() else {
rhs()
}
return _lhs
}
let offset = "ABC".firstIndex(of: "D") ?? preconditionFailure() // failure
or just rewrite it as guard let offset = letters.firstIndex(of: fragment) else { preconditionFailure() }
which is pretty close to the original.