August 01, 2013 [Issue 10741] New: A delegate in a variable initializer cannot see the variable | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=10741 Summary: A delegate in a variable initializer cannot see the variable Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: andrej.mitrovich@gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-08-01 12:05:25 PDT --- This is an interesting limitation: ----- struct Foo { this(void delegate()) { } void test() { } } void main() { Foo foo1; foo1 = Foo({ foo1.test(); }); // ok Foo foo2 = Foo({ foo2.test(); }); // L14: error } ----- $ dmd test.d > test.d(14): Error: undefined identifier foo2, did you mean variable foo1? It seems the delegate cannot see the 'foo2' variable yet. I'm not sure if there would be any problems making this work? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 01, 2013 [Issue 10741] A delegate in a variable initializer cannot see the variable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | http://d.puremagic.com/issues/show_bug.cgi?id=10741 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim@maxim-fomin.ru --- Comment #1 from Maxim Fomin <maxim@maxim-fomin.ru> 2013-08-01 12:19:09 PDT --- Yes, because a declaration with initializer is not finished in the point of initializer. This is a basic feature in D. void main() { @((int i)=>a) int a; //error auto b = { return b; } ; //error } However nothing is wrong with making this limitation gone. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation