[Issue 5655] Lambda inside static foreach saves wrong value of counter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 18 22:34:58 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5655
hsteoh at quickfur.ath.cx changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
CC| |hsteoh at quickfur.ath.cx
Resolution| |FIXED
--- Comment #5 from hsteoh at quickfur.ath.cx 2013-08-18 22:34:55 PDT ---
This bug appears to have been fixed in the latest git HEAD. To prove that it
has really been fixed (not just have a different wrong value for i captured), I
expanded the code slightly:
------
import std.stdio, std.typetuple;
void main()
{
TypeTuple!(int, float, real) TT;
void function() funs[3];
foreach (i, T; TT)
{
funs[i] = function { writeln(i); };
}
funs[1]();
funs[2]();
}
------
The output is:
1
2
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list