https://issues.dlang.org/show_bug.cgi?id=15094
Issue ID: 15094 Summary: __traits(getMember) fails when the source is a struct/class field Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: initrd...@gmail.com Attempting to use `__traits(getMember)` with a sub-struct/field fails with a `need 'this'` error. Example code: import std.stdio; struct Foo { int i; } struct Bar { Foo foo; } void main() { Bar bar; writeln(__traits(getMember, bar.foo, "i")); } Output: $ rdmd ~/test.d /home/col/test.d(14): Error: need 'this' for 'i' of type 'int' Failed: ["dmd", "-v", "-o-", "/home/col/test.d", "-I/home/col"] It's possible, but annoying, to work around this by storing a local pointer to the field first. auto foo = &bar.foo; writeln(__traits(getMember, foo, "i")); --