On Monday, 22 August 2022 at 04:39:18 UTC, Andrey Zherikov wrote:
I have this simple code:
```d
struct U
{
auto ref func(int i)() { return this; }
}
void main()
{
{
alias type = typeof(U().func!0);
pragma(msg, type); // pure nothrow @nogc ref @safe
U() return
pragma(msg, is(type : U)); // false
auto u = U().func!0;
pragma(msg, typeof(u)); // U
}
{
alias type = typeof(U().func!0());
pragma(msg, type); // U
pragma(msg, is(type : U)); // true
auto u = U().func!0();
pragma(msg, typeof(u)); // U
}
}
```
Why does `typeof(U().func!0)` != `U`? How can I check that the
returned value has type `U` in this case?
Why not just change to:
alias type = typeof(U().func!0());