Checking if a type is void
Paul Backus
snarwin at gmail.com
Sat May 28 14:43:13 UTC 2022
On Saturday, 28 May 2022 at 14:37:42 UTC, Stefan Koch wrote:
> Yes indeed!
> If you try
> ```d
> alias T = void*;
> alias U = typeof(*T);
> static assert(is(U == void));
> ```
>
> You will the the compiler complaining about void having no
> value,
> which indicates that the initValue is indeed the mechanism of
> operation here.
Interestingly, there are some operators that cause the compiler
to catch the error:
```d
alias T = int*;
alias U = typeof(T[0 .. 0]);
// Error: cannot slice type `int*`
```
So I guess this is just a case of missing checks in the semantic
analysis of certain kinds of expressions.
More information about the Digitalmars-d
mailing list