[Issue 19167] Overzealous "Using this as a type is deprecated"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Aug 14 12:53:42 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19167

--- Comment #3 from ag0aep6g <ag0aep6g at gmail.com> ---
(In reply to John Colvin from comment #2)
> How about this, which the compiler is OK with:
> 
> struct A
> {
>     alias a = int;
> }
> 
> struct B
> {
>     A a;
>     alias b = a.a;
> }
> 
> I don't understand the logic that says we can't directly access compile-time
> members of `this` at struct scope but we can access compile-time members of
> member variables.

I think you're right. If we can use `a` that way, we should be able to use
`this`, too. There's also this:

----
struct A
{
    enum a = 1;
    enum b = this.a; /* no deprecation */
}
----

So DMD doesn't reject all cases of `this`. If the enum is acceptable, the alias
in the original snippet should be acceptable, too.

--


More information about the Digitalmars-d-bugs mailing list