digitalmars.D.bugs - [Issue 16137] New: Better error message: function literal accessing
- via Digitalmars-d-bugs (33/33) Jun 07 2016 https://issues.dlang.org/show_bug.cgi?id=16137
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 puremagic.com Reporter: jbc.engelen 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 --
Jun 07 2016