bottom type as parameter or local variable, does that make sense?

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Jan 14 15:07:13 UTC 2022


On Fri, Jan 14, 2022 at 02:05:25PM +0000, vit via Digitalmars-d wrote:
> On Friday, 14 January 2022 at 13:58:38 UTC, H. S. Teoh wrote:
> > On Fri, Jan 14, 2022 at 11:52:04AM +0000, WebFreak001 via Digitalmars-d
> > wrote:
> > > ```d
> > [...]
> > > void bar()
> > > {
> > >     noreturn b;
> > >     writeln("calling");
> > >     foo(b);
> > > }
> > [...]
> > > ```
> > 
> > Wait, doesn't the DIP say that while declaring a variable of type
> > `noreturn` is technically allowed, it should abort at runtime as
> > soon as the variable is initialized?  Why is program actually
> > running past that line??!
[...]
> Whith explicit init it works like that:
> 
> ```d
> import std.stdio;
> 
> 
>     void main(){
>         noreturn n = noreturn.init;
>         writeln("bar");
>     }
> 
> ```
> Print:
> ```
> //Illegal instruction (core dumped)
> ```

IMO, that's a bug.  Implicit initialization of noreturn should behave
exactly the same way as invoking noreturn.init explicitly.

Somebody should file a bug, if one hasn't been filed already.


T

-- 
We are in class, we are supposed to be learning, we have a teacher... Is it too much that I expect him to teach me??? -- RL


More information about the Digitalmars-d mailing list