Bug 13343 – Strange behaviour aliasing struct members

Status
NEW
Severity
normal
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-08-20T14:24:24Z
Last change time
2024-12-13T18:24:32Z
Assigned to
No Owner
Creator
Manu
Depends on
20863, 20884
Moved to GitHub: dmd#18870 →

Comments

Comment #0 by turkeyman — 2014-08-20T14:24:24Z
Can anyone explain this to me: struct S { int x; } alias T = immutable(S); enum member = "x"; import std.typetuple; alias AliasMember(T, string member) = Alias!(__traits(getMember, T, member)); alias AliasMember2(T, string member) = Alias!(mixin("T."~member)); pragma(msg, typeof(AliasMember!(T, member)).stringof); pragma(msg, typeof(AliasMember2!(T, member)).stringof); pragma(msg, typeof(__traits(getMember, T, member)).stringof); pragma(msg, typeof(mixin("T."~member)).stringof); Output: 1>int 1>int 1>int 1>immutable(int) I don't understand... the 4th one get's it right, it is immutable(int). The traits lookups seem to lose the immutable part from T. (is this a bug?) But the real surprise here is the second one; the same mixin lookup piped through an alias loses the immutable part too... that can't be right? Something can't be right here... :/ I would have expected all four to be immutable(int)...?
Comment #1 by boris2.9 — 2020-05-30T13:29:50Z
The first two cases are duplicated of issue 20863. The third case I reported it as issue 20884 and made a patch.
Comment #2 by robert.schadek — 2024-12-13T18:24:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18870 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB