[Issue 13189] New: `alias this` is not transitive
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Jul 22 10:43:53 PDT 2014
    
    
  
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 at puremagic.com
          Reporter: hsteoh at 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'.
--
    
    
More information about the Digitalmars-d-bugs
mailing list