[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.

2022-12-17 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=20884

Iain Buclaw  changed:

   What|Removed |Added

   Priority|P1  |P3

--


[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.

2022-01-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=20884

--- Comment #4 from Boris Carvajal  ---
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.

--


[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.

2022-01-26 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=20884

Mathias LANG  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||pro.mathias.l...@gmail.com
 Resolution|FIXED   |---

--- Comment #3 from Mathias LANG  ---
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.

--


[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.

2020-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=20884

Dlang Bot  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from Dlang Bot  ---
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

--


[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.

2020-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=20884

Boris Carvajal  changed:

   What|Removed |Added

 Blocks||13343


Referenced Issues:

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


[Issue 20884] Using getMember with a type as first argument can lose type qualifiers.

2020-05-30 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=20884

Dlang Bot  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #1 from Dlang Bot  ---
@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

--