[Issue 4209] New: Can not return from foreach over associative array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed May 19 09:55:37 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4209
Summary: Can not return from foreach over associative array
Product: D
Version: 2.041
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: wrong-code
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: Jesse.K.Phillips+D at gmail.com
CC: Jesse.K.Phillips+D at gmail.com
--- Comment #0 from Jesse Phillips <Jesse.K.Phillips+D at gmail.com> 2010-05-19 09:55:33 PDT ---
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;
}
--
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