Thread overview
[Issue 19167] Overzealous "Using this as a type is deprecated"
Aug 14, 2018
ag0aep6g
Aug 14, 2018
John Colvin
Aug 14, 2018
ag0aep6g
Nov 05, 2018
RazvanN
Jul 27, 2019
Mike Franklin
Dec 17, 2022
Iain Buclaw
August 14, 2018
https://issues.dlang.org/show_bug.cgi?id=19167

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ag0aep6g@gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
In the first case, there is no `this` object, so DMD interprets it to mean the type of `this`. That's been deprecated.

In the second case, there is an `a` object. The alias is still the same as `typeof(a).a`, but that's ok. Making the alias has not been deprecated. The deprecation is about using `this` where there is no object `this`.

Similarly, you can still use `alias b = this.a;` inside a method:

----
struct A
{
    alias a = int;
    void m()
    {
        alias b = this.a; /* no deprecation */
    }
}
----

I'm closing this as invalid. As usual, feel free to reopen if I missed something.

--
August 14, 2018
https://issues.dlang.org/show_bug.cgi?id=19167

John Colvin <john.loughran.colvin@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from John Colvin <john.loughran.colvin@gmail.com> ---
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.

--
August 14, 2018
https://issues.dlang.org/show_bug.cgi?id=19167

--- Comment #3 from ag0aep6g <ag0aep6g@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.

--
November 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19167

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #4 from RazvanN <razvan.nitu1305@gmail.com> ---
I think that the real bug is that in the enum case the deprecation should be triggered.

--
July 27, 2019
https://issues.dlang.org/show_bug.cgi?id=19167

Mike Franklin <slavo5150@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slavo5150@yahoo.com

--- Comment #5 from Mike Franklin <slavo5150@yahoo.com> ---
> I think that the real bug is that in the enum case the deprecation should be triggered.

I agree.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19167

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--