Bug 4209 – Can not return from foreach over associative array

Status
RESOLVED
Resolution
DUPLICATE
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-05-19T09:55:00Z
Last change time
2014-02-15T02:45:37Z
Keywords
wrong-code
Assigned to
nobody
Creator
Jesse.K.Phillips+D

Comments

Comment #0 by Jesse.K.Phillips+D — 2010-05-19T09:55:33Z
The code below demonstrates that even though the function can only return 'false' it will return 'true' This is with DMD 2.043 void main() { assert(success() == false); } bool success() { auto arr = ["Hello":"Misty", "There":"Cats"]; foreach(a; arr) if(a == "Cats") { return false; } else if(a == "Misty") { } else assert(false, "Should never get here."); return true; }
Comment #1 by schveiguy — 2010-05-19T10:15:28Z
This was recently fixed in 2.046. Building your code with 2.046 compiles and runs as expected (no assertion). *** This issue has been marked as a duplicate of issue 4184 ***
Comment #2 by Jesse.K.Phillips+D — 2010-05-19T13:59:09Z
Thanks I would have never guessed they were the same issue.