Thread overview
[Issue 21288] Wrong context pointer for alias this function
Oct 01, 2020
Mathias LANG
Oct 01, 2020
Richard Manthorpe
Oct 02, 2020
Mathias LANG
Dec 17, 2022
Iain Buclaw
Mar 08, 2023
Dlang Bot
Mar 13, 2023
Dlang Bot
Mar 16, 2023
Dlang Bot
October 01, 2020
https://issues.dlang.org/show_bug.cgi?id=21288

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--- Comment #1 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Wait, is this code even valid ?

Here in `C.foo` & `foo` you are calling `B.p`, as a shortcut for `B.a.p`, but
`a()` is not static, hence you should not be able to do that.
Indeed if you change the expression to `B.a.p` it gives you a proper error
message. So the second case is an accept-invalid, and the first case could use
with a better error message.

--
October 01, 2020
https://issues.dlang.org/show_bug.cgi?id=21288

--- Comment #2 from Richard Manthorpe <rmanth@gmail.com> ---
It feels like it should be valid. If there is an `alias this` you should really have to know whether something is in `B` or `A`. Since you can do things like `A.p.stringof` or `__traits(getAttributes, A.p)` which requires a symbol, you should probably also be able to do `B.p.stringof` or `__traits(getAttributes, B.p)`.

--
October 02, 2020
https://issues.dlang.org/show_bug.cgi?id=21288

--- Comment #3 from Mathias LANG <pro.mathias.lang@gmail.com> ---
Right, because it's `stringof`. Just tested and it also trigggers with
`__traits(identifier)`.

A workaround for this issue would be to use the following:
```
static assert(__traits(identifier, typeof(B.init.a()).p) == "p");
```
Which works as expected.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--
March 08, 2023
https://issues.dlang.org/show_bug.cgi?id=21288

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #14969 "Fix Issue 21288 & 10886 - incorrect this pointer" fixing this issue:

- Fix Issue 21288 & 10886 - incorrect this pointer

https://github.com/dlang/dmd/pull/14969

--
March 13, 2023
https://issues.dlang.org/show_bug.cgi?id=21288

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14969 "Fix Issue 21288 & 10886 - incorrect this pointer" was merged into stable:

- 30a91c21347eaaebd8b27bb4598726422110c555 by RazvanN7:
  Fix Issue 21288 & 10886 - incorrect this pointer

https://github.com/dlang/dmd/pull/14969

--
March 16, 2023
https://issues.dlang.org/show_bug.cgi?id=21288

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #14992 "merge stable" was merged into master:

- 141c5683f69d5a483d6f1647950249510a025961 by Razvan Nitu:
  Fix Issue 21288 & 10886 - incorrect this pointer (#14969)

https://github.com/dlang/dmd/pull/14992

--