Thread overview
[Issue 21288] Wrong context pointer for alias this function
October 01
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
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
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.

--