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

Paul Backus snarwin at gmail.com
Mon Jan 17 17:57:19 UTC 2022


On Monday, 17 January 2022 at 16:11:03 UTC, Timon Gehr wrote:
> In D, types that do not have a default constructor cannot be 
> default-constructed. The question is whether `noreturn`, the 
> empty type, should really have a default constructor (that 
> immediately terminates the program). As far as I understand, 
> according to the DIP, `noreturn` has a default constructor, but 
> `noreturn` variables are initialized lazily when they are 
> accessed.

I think the best way to describe the behavior specified by the 
DIP is that the compiler rewrites

     noreturn x;

to

     noreturn x = void;

So, there is a special case here, but it does not require 
noreturn to have a default constructor.


More information about the Digitalmars-d mailing list