Thread overview
[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.
May 30, 2020
Dlang Bot
May 30, 2020
Boris Carvajal
May 30, 2020
Dlang Bot
Jan 26, 2022
Mathias LANG
Jan 27, 2022
Boris Carvajal
Dec 17, 2022
Iain Buclaw
May 30, 2020
https://issues.dlang.org/show_bug.cgi?id=20884

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

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

--- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> ---
@BorisCarvajal created dlang/dmd pull request #11200 "Fix Issue 20884 - Using getMember with a type as first argument can l…" fixing this issue:

- Fix Issue 20884 - Using getMember with a type as first argument can lose type qualifiers.

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

--
May 30, 2020
https://issues.dlang.org/show_bug.cgi?id=20884

Boris Carvajal <boris2.9@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |13343


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=13343
[Issue 13343] Strange behaviour aliasing struct members
--
May 30, 2020
https://issues.dlang.org/show_bug.cgi?id=20884

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

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

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11200 "Fix Issue 20884 - Using getMember with a type as first argument can l…" was merged into stable:

- aa33b64dfbe78a6621314472e1ad88ea5aa2afcb by Boris Carvajal:
  Fix Issue 20884 - Using getMember with a type as first argument can lose type
qualifiers.

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

--
January 26, 2022
https://issues.dlang.org/show_bug.cgi?id=20884

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |pro.mathias.lang@gmail.com
         Resolution|FIXED                       |---

--- Comment #3 from Mathias LANG <pro.mathias.lang@gmail.com> ---
This wasn't fully fixed. Ran into this one today:
```
pragma(msg, __VERSION__);

template FieldRef (T, string name)
{
        alias Ref = __traits(getMember, T, name);

        alias Type1 = typeof(Ref);
        alias Type2 = typeof(__traits(getMember, T, name));

    pragma(msg, "Instantiating FieldRef: ", T, ".", name, " => ", Type1, "
versus ", Type2);
}

struct Config
{
        Inner inner;
}

struct Inner
{
        char[] value;
}

alias IConfig = immutable(Config);
alias Result = FieldRef!(IConfig, `inner`);
alias ResultBis = FieldRef!(Result.Type2, "value");
```

Result:
```
2098L
Instantiating FieldRef: immutable(Config).inner => Inner versus
immutable(Inner)
Instantiating FieldRef: immutable(Inner).value => char[] versus
immutable(string)
```

As you can see, using the `__traits` directly works, but using an `alias` to the `__traits` still has the bug. This was tested with nightly (2.098), the aforementioned PR was released in v2.092.

--
January 27, 2022
https://issues.dlang.org/show_bug.cgi?id=20884

--- Comment #4 from Boris Carvajal <boris2.9@gmail.com> ---
That is an alias bug, replace the getMember trait with 'mixin("T." ~ name)' in
your code and the result is the same.
```
alias Ref = mixin("T." ~ name);
...
alias Type2 = typeof(mixin("T." ~ name));
```

I think it's duplicated of issue 2704 (really old, probably there are more
reports out there).
Some different but related bugs are issue 13343 and issue 20863.

There is a generic alias problem with respect to aggregate types (that have qualifiers) because the duality of them being a symbol and type at the same time, it also extends when interacting with their members.

This report was about fixing '__traits(getMember)' so maybe you should move the test case to 2704 and keep this closed.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--
December 13
https://issues.dlang.org/show_bug.cgi?id=20884

--- Comment #5 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19713

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--