[Issue 4131] New: break does not work correctly with foreach and associative arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 27 15:01:59 PDT 2010
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: nobody at puremagic.com
ReportedBy: ludwig at informatik.uni-luebeck.de
--- Comment #0 from Sönke Ludwig <ludwig at 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.AssertError at test(12): Assertion failure
---
--
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