`this` and nested structs

Mike Franklin slavo5150 at yahoo.com
Thu May 10 03:23:50 UTC 2018

Consider the following code:

struct S
     // intentionally not `static`
     struct SS
         int y() { return x; }  // Error: need `this` for `x` of 
type `int`

     int x;
     SS ss;

void main()
     S s;

If I change `return x;` to `return this.x;` then of course it 
emits the following error:

Error: no property `x` for type `SS`

My understanding is that `SS` should have a context pointer to an 
instance of `S`, but how do I navigate the members of `S` and 
`SS`.  Is this a bug?


My understanding is that nested structs have an implicit context 
pointer to their containing scope.

More information about the Digitalmars-d-learn mailing list