Thread overview
[Issue 12363] getProtection trait doesn't work for certain kinds of fields (and is poorly designed...)
Dec 19, 2014
Luca Niccoli
Dec 17, 2022
Iain Buclaw
Nov 17, 2023
Jonathan M Davis
[Issue 12363] getVisibility trait doesn't work for certain kinds of fields (and is poorly designed...)
Nov 17, 2023
Jonathan M Davis
December 19, 2014
https://issues.dlang.org/show_bug.cgi?id=12363

Luca Niccoli <lultimouomo@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lultimouomo@gmail.com

--- Comment #1 from Luca Niccoli <lultimouomo@gmail.com> ---
On the same vein:

---
struct Template(string String) {
    alias Alias = String;
}
pragma(msg, __traits(getProtection, __traits(getMember, Template!"string",
"Alias")));
---

Output:
---
app.d(4): Error: argument "string" has no protection
false
---

And a bit different, but related:

---
struct Struct{};
struct Template(Type) {
    private alias Alias = Type;
}
pragma(msg, __traits(getProtection, __traits(getMember, Template!Struct,
"Alias")));
---

Output:
---
public
---

which does not seem right.
Going through getMember makes it impossible to get the protection attribute of
member aliases.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
November 17, 2023
https://issues.dlang.org/show_bug.cgi?id=12363

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #2 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
This just came up in the learn newsgroup again:

---
struct bar {
     public alias pubInt = int;
     private alias privInt = int;
}

static foreach(member ; __traits(allMembers, bar)) {
     // Error: argument `int` has no visibility
     pragma(msg, __traits(getVisibility, __traits(getMember, bar, member)));
}
---

I would guess that the core problem here is that the alias gets replaced with what it's an alias to before getVisibility actually operates on it, which is obviously the wrong order to do things in.

--
November 17, 2023
https://issues.dlang.org/show_bug.cgi?id=12363

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|getProtection trait doesn't |getVisibility trait doesn't
                   |work for certain kinds of   |work for certain kinds of
                   |fields (and is poorly       |fields (and is poorly
                   |designed...)                |designed...)

--