DIP 1017--Add Bottom Type--Community Review Round 1

Andrea Fontana nospam at example.com
Fri Aug 10 07:19:02 UTC 2018


On Friday, 10 August 2018 at 07:01:09 UTC, Petar Kirov 
[ZombineDev] wrote:
>
> `is(T == U)` evaluates to true iff `T` is exactly `U`. `is(T : 
> U)` tests if `T` is a subtype of (can be implicitly converted 
> to) `U` [0]. So we have:
>
> `is(typeof(assert(0)) == T)` is false, unless `T` is 
> `typeof(assert(0))`
> `is(typeof(assert(0)) : T)` is always true (as bottom is 
> implicitly convertible to any other type, including itself).
>
> [0]: https://dlang.org/spec/expression#is_expression

So if I need to write something like:

void callback(alias T)() if(is(ReturnType!T ==  int))
{
}

I have to change it to:
void callback(alias T)() if(is(ReturnType!T ==  int) || 
is(ReturnType!T == typeof(assert(0)))
{
}

?




More information about the Digitalmars-d mailing list