Efforts to make force-unwrapping more visible by making it more verbose faired poorly in review and are unlikely to make it into the langauge. I like the idea personally, but it looks like it will forever be an idea that lives in user extensions. (Here's the self-documenting one I use, and how it looks in context.)
However, making Never a true bottom type does always seem to get support whenever it comes up. I see @suyashsrijan already linked to the recent discussion. I'd love to see the questions in that thread resolved. (Also, nice trick making ?? handle rhs Never like that.)
My post about Never linked above is a little out-of-date, but I have a WIP PR on making Never a bottom type here. I haven't had much time to work on it in the past few weeks but I'm hoping to get back to it soon. There are unfortunately some complications around source + ABI compatibility, but I think they can all be resolved.
Personally, while I usually discourage its use, I wouldn't want for ! to go away. It's a useful tool in some situations (e.g. especially in scripts, which is one of the goals for Swift 6 I believe).
I do encourage a progression of Never to become a real bottom type though, but I didn't see anyone really against it
First, as many others here would point out, this is source-breaking and thus is very unlikely to be adopted.
That said, I think this is part of a wider class of issues where Swift isnāt quite as safe as I would like for certain cases. Iād really love an annotation we could use for such cases, in this case something like āno fatal errorsā, which could apply to either the function, type, file, or target scope. This would make it very clear that there are no force unwrappings in that code. (Note that even this is nuanced because currently things like Int.+ crashes on overflow, and we may want to automatically use a variant which throws an error instead)
Another thing like this I would like is āno unsafeā, maybe both of these are actually part of a single concept like āsafe modeā.
Note that crashing is one way in which safety is guaranteed. When an invariant is violated, stopping execution is safe, while continuing is unsafe. This is the sense in which Swift uses the term "safe."
Nice formulation. This seems like a no-brainer add to the stdlib to me. (Not mutually exclusive with a proper bottom type, just a bridge between here and there.)
which sadly bumps into an annoyance with type inference.
This one specifically when Void is to be inferred in a function (and no explicit return), though really what I'd be after is Never being an actual bottom type so it could be used in such ways: func f() { TODO() } as well as let x: SomeX = TODO() would be able to work more nicely, with just one definition. So yeah, would be nice to have Never be an actual bottom type, though no idea why it isn't today
Yeah, though sadly I've amended my reply above -- does not really make a difference.
Sure, but it's fairly common and useful to defined "todo" and "undefined"'s in laguanges which have a bottom type (e.g. we'd use tons ofdef foo: String = ??? in Scala (where ??? returns Nothing (the bottom type)) to make placeholders while WIPing a shape of an API. One could argue it's not useful for much else other than those "placeholder" functions but yeah, it's quite nice to have.