[Issue 16137] New: Better error message: function literal accessing class variable
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jun 7 09:04:15 PDT 2016
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: nobody at puremagic.com
Reporter: jbc.engelen at gmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list