The with statement does not appear to take alias this into account: ---- void test(T)(T t) { } struct Foo { string[string] strs; alias strs this; } void main() { Foo f; test(f.keys[0]); // Fine with(f) { test(keys[0]); // Not fine } } ---- test.d(15): Error: undefined identifier keys Using dmd 2.062.
*** This issue has been marked as a duplicate of issue 6711 ***
This was not a dupe of issue 6711, it asks for properties of built-in types to be accessible via with. eg this doesn't work void main() { int[int] aa; with(aa) { } } Making this work for AAs is questionable, as this doesn't work: void main() { struct S { int[] a; alias a this; } S x; with(x) { length; } }