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