proposed @noreturn attribute

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 9 19:44:09 PDT 2017


Let's call the bottom type 'B' for the moment, for convenience.

If we think of it like a floating point NaN, then any type construction of B 
yields a B:

     const(B) -> B
     B* -> B
     B[] -> B
     X[B] -> B
     B[X] -> B

Since B cannot have a value, any expression that forms a B can be replaced with 
an assert(0).

     B foo(); // declaration
     foo() -> foo(); assert(0);

     cast(B)exp -> exp; assert(0);

     B b; -> assert(0);

Given a tuple of types:

     alias T = tuple(B,X);

is T equivalent to which of:

     B           (1)
     tuple(X)    (2)
     tuple(Y,X)  (3)
     tuple(B,X)  (4)

? I'm leaning toward (4) as making the most sense.

     struct S {
        T t;
     }

should then yield an error, while:

     struct S {
        T[1..1] t; // t is of type X
     }

would not.


More information about the Digitalmars-d mailing list