www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18601] New: alias m = __traits(getMember, ...) doesn't work


          Issue ID: 18601
           Summary: alias m = __traits(getMember, ...) doesn't work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

It's annoying that this doesn't work:

struct S
    int x;

void f()
    S s;
    alias m = __traits(getMember, s, "x");

 Error: basic type expected, not `__traits`
 Error: semicolon expected to close `alias` declaration
I'm pretty sure this could be trivially supported...? I feel like that __traits statement should be semantically identical to: alias m = s.x; The __traits(getMember) docs make you feel like that's true... --
Mar 12 2018