digitalmars.D.bugs - [Issue 16123] New: alias member of member
- via Digitalmars-d-bugs (41/41) Jun 04 2016 https://issues.dlang.org/show_bug.cgi?id=16123
https://issues.dlang.org/show_bug.cgi?id=16123 Issue ID: 16123 Summary: alias member of member Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: schveiguy yahoo.com Currently, you can alias a member of your struct no problem: struct S { int x; alias y = x; } If I want to alias a member of a member, it does not work: struct T { S s; alias y = s.x; // note, this compiles just fine, you need to use it to flag the error. } void main() { T t; t.s.y = 5; // ok t.y = 5; // Error: need 'this' for 'x' of type 'int' } To me, this doesn't make sense. The requirements shouldn't be any different, if I can alias a member, I should be able to alias a member's member, especially if the member is a field. I'm not sure if this is an enhancement or a bug. Flagging as bug, change if necessary. Note, in older versions of the compiler (2.069 and earlier), I get an additional error: Error: struct testalias.T 'x' is not a member --
Jun 04 2016