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.
Comment #1 by andrej.mitrovich — 2013-06-09T12:01:53Z
*** This issue has been marked as a duplicate of issue 6711 ***
Comment #2 by yebblies — 2013-11-22T03:32:31Z
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;
}
}