"I told you so": noreturn sucks a leech and has virtually no utility

Dennis dkorpel at gmail.com
Fri Oct 15 18:46:50 UTC 2021


On Friday, 15 October 2021 at 17:13:29 UTC, Andrei Alexandrescu 
wrote:
> Thirty-seven `noreturn` occurrences in phobos.
>
> Ten opened bugs.

Some context for this: On February 16 this year, Mike Parker 
informed me that [DIP1034](dlang.org/dips/1034) was accepted and 
we were discussing the implementation at that time.

> Do you plan to implement the feature or should I hand this off 
> to Andrew & Razvan to oversee it?

A fews days later, the first PR appeared by Walter, [DIP1034: add 
typeof(*null)](https://github.com/dlang/dmd/pull/12209). From 
this it looked like Walter was going to take care of it, so that 
conversation ended there.

However, after implementing `noreturn exit()` through his 
favorite style of incremental improvements, Walter abandoned it, 
leaving DIP1034 in like a <10% implemented state. No thorough 
testing, no specification, no `throw` expressions, no 
`typeof([])`, no new `typeof(null)`, no core.demangle support, 
etc.

Then a new dmd release came, which included the new `noreturn` 
type in object.d without any preview switches, but still totally 
unfinished. Of course bug reports were going to come.

Later, other people (among which MoonlightSentinel) started 
picking up the loose ends by chasing down those bugs. They 
stumbled on the misfeature that is 'warnings', particularly the 
"statement not reachable" one. The compiler became smarter about 
unreachable code, e.g. `case X: exit(); break;` now generates a 
warning about the unreachable `break` statement.

These warnings also manifest in some of Phobos' generic code, and 
since some people compile with `-w` which treats warnings as 
errors, this spawned some special case `static if` for 
`noreturn`. IMO it's better to get rid of that awful warning (at 
the very least in generic code) so those cases can be removed.

I haven't looked too deep at `isAutodecodableString`, but it may 
say more about auto decoding than `noreturn`. There's already 
this ugly signature:
```
void popFront(T)(scope ref inout(T)[] a) @safe pure nothrow @nogc
if (!isAutodecodableString!(T[]) && !is(T[] == void[]))
```


More information about the Digitalmars-d mailing list