---
cat > test.d << code
struct A
{
void call(void delegate() dg) {dg();}
}
struct B
{
int f;
void m()
{
A a;
a.call({auto err = f;});
}
}
bool go()
{
B b;
b.m();
return true;
}
static assert(go());
code
dmd -c test.d
---
test.d(12): Error: couldn't find field f of type int in A()
test.d(3): called from here: dg()
test.d(12): called from here: a.call(delegate ()
{
int err = this.f;
}
)
test.d(19): called from here: b.m()
test.d(23): called from here: go()
test.d(23): while evaluating: static assert(go())
---
The error message says "couldn't find field [...] in A()", when the field should be looked up in B. The error remains the same even when a field f is added to A.
This also affects opApply.
Comment #1 by k.hara.pg — 2015-07-09T04:37:16Z
Related issue: 9541
Comment #2 by robert.schadek — 2024-12-13T18:16:34Z