Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange behaviour aliasing struct members #18870

Open
dlangBugzillaToGithub opened this issue Aug 20, 2014 · 1 comment
Open

Strange behaviour aliasing struct members #18870

dlangBugzillaToGithub opened this issue Aug 20, 2014 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Manu reported this on 2014-08-20T14:24:24Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=13343

CC List

  • Boris Carvajal

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)...?
@dlangBugzillaToGithub
Copy link
Author

boris2.9 commented on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant