https://issues.dlang.org/show_bug.cgi?id=16137
Issue ID: 16137
Summary: Better error message: function literal accessing class
variable
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
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
--