digitalmars.D.bugs - [Issue 13189] New: `alias this` is not transitive
- via Digitalmars-d-bugs (44/44) Jul 22 2014 https://issues.dlang.org/show_bug.cgi?id=13189
https://issues.dlang.org/show_bug.cgi?id=13189 Issue ID: 13189 Summary: `alias this` is not transitive Product: D Version: D2 Hardware: x86 OS: Linux Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: hsteoh quickfur.ath.cx Code: ------ import std.typecons : TypeTuple; struct S { int x; int y; } struct T { S s; alias s this; } static assert(is(typeof(T.init.x))); static assert(is(typeof(T.init.y))); struct U { T t; //alias x = t.x; // <-- FAIL alias x = t.s.x; // <-- OK } void main() { } ------ The line marked "FAIL" does not compile if uncommented: ------ test.d(18): Error: need 'this' for 's' of type 'S' ------ The following line works. But it should not be necessary to specify '.s' here, since the static asserts before the definition of struct U show that '.x' and '.y' can be accessed directly given an instance of T, due to the `alias s this`. So it should be possible to alias the symbol directly without needing to specify '.s'. --
Jul 22 2014