http://d.puremagic.com/issues/show_bug.cgi?id=4131
Summary: break does not work correctly with foreach and associative arrays Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: lud...@informatik.uni-luebeck.de --- Comment #0 from S�nke Ludwig <lud...@informatik.uni-luebeck.de> 2010-04-27 15:01:57 PDT --- Issuing a break statement will not cause the foreach loop to exit but instead will perform another iteration before jumping out. --- import std.stdio; void main() { int[int] test; test[0] = 0; test[1] = 1; bool flag = false; foreach( k, v; test){ writefln("loop: %s %s", k, v); assert(!flag); // fails on second loop! flag = true; break; // should exit here after the first iteration } } --- output: --- loop: 0 0 loop: 1 1 core.exception.asserter...@test(12): Assertion failure --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------