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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 12 19:10:14 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18601

          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 at puremagic.com
          Reporter: turkeyman at 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...

--


More information about the Digitalmars-d-bugs mailing list