digitalmars.D.bugs - [Issue 2228] New: Full closure does not honor loop context
- d-bugmail puremagic.com (32/32) Jul 15 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2228
- d-bugmail puremagic.com (10/10) Jul 27 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2228
http://d.puremagic.com/issues/show_bug.cgi?id=2228 Summary: Full closure does not honor loop context Product: D Version: 2.015 Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: benoit tionex.de With DMD 2.015: alias void delegate() Runner; void main(){ Runner[] runners; for( int i = 0; i < 3; i++ ){ const int ci = i; runners ~= delegate(){ writefln( "run with ci=%d", ci ); }; } foreach( runner; runners ){ runner(); } } Output: run with ci=2 run with ci=2 run with ci=2 It should be 0,1,2. --
Jul 15 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2228 brunodomedeiros+bugz gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE My example is a bit less clear, but it's the same bug. *** This bug has been marked as a duplicate of 2043 *** --
Jul 27 2008