[Issue 22011] traits(getMember, Anything, "this") does not bypass visibility

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jun 16 07:16:39 UTC 2021


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |pro.mathias.lang at gmail.com
         Resolution|---                         |INVALID

--- Comment #4 from Mathias LANG <pro.mathias.lang at gmail.com> ---
The bug is not about visibility, but trying to use `this` to access the ctor.
If you make `this` public, you'll still get the same error message.

> __ctor is not returned by allMembers

It is. https://dlang.org/spec/traits.html#allMembers
We use it directly because there's no alternative.

> But then for "this", it fails, even though traits(allMembers) returns it, causing an annoying special case.

When I add:
> pragma(msg, __traits(allMembers, A));

After the other, I get:
> tuple("__ctor", "foo", "toString", "toHash", "opCmp", "opEquals", "Monitor", "factory")

How do you get the `"this"` ?

--


More information about the Digitalmars-d-bugs mailing list