You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)...?
The text was updated successfully, but these errors were encountered:
Manu reported this on 2014-08-20T14:24:24Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=13343
CC List
Description
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)...?The text was updated successfully, but these errors were encountered: