bottom type as parameter or local variable, does that make sense?
bauss
jj_1337 at live.dk
Fri Jan 14 15:55:54 UTC 2022
On Friday, 14 January 2022 at 15:07:13 UTC, H. S. Teoh wrote:
> 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
Why is it even allowed, that's beyond my understanding?
More information about the Digitalmars-d
mailing list