This code
```
class A
{
int i;
void foo()
{
auto a = function() { i++; }; // Line 6
}
}
```
gives the error (DMD 2.071):
foo.d(6): Error: need 'this' for 'i' of type 'int'
I think it should be improved, but I do not have a great idea for it. It think instead of mentioning "need 'this'" it should mention something about "delegate" or "function literal needs access to object data", ...
Thanks,
Johan
Comment #1 by robert.schadek — 2024-12-13T18:48:23Z