bottom type as parameter or local variable, does that make sense?
snarwin at gmail.com
Sat Jan 15 00:54:03 UTC 2022
On Friday, 14 January 2022 at 22:55:37 UTC, Max Samukha wrote:
> On Friday, 14 January 2022 at 16:32:22 UTC, Paul Backus wrote:
>> That's not what the bug is here. `noreturn` is the type of
>> expressions whose evaluation does not halt; i.e., it is a type
>> with no values. Therefore, declaring a variable of type
>> `noreturn` is a no-op: all it does is add a symbol to the
>> current scope. No initialization is performed, because there
>> is nothing to initialize.
> Then, should "noreturn x = noreturn.init;" fail? In my world,
> it is equivalent to "noreturn x;". There is still an implicit
> initialization, which should halt.
My point is, they're not equivalent.
* Execution of `noreturn x = noreturn.init;` requires evaluating
the *expression* `noreturn.init`.
* Execution of `noreturn x;` does not require evaluating anything.
Yes, this is an exception to the general rule that `T x = T.init`
and `T x;` are equivalent.
Why does this exception exist? Because for any type `T` other
than `noreturn`, the expression `T.init` evaluates to a value of
type `T`. However, the expression `noreturn.init` does not
evaluate to a value of type `noreturn`--because, as previously
stated, *there is no such thing as a value of type `noreturn`*.
More information about the Digitalmars-d