Guest mantragora Posted September 26, 2015 Share Posted September 26, 2015 (edited) Hi! So we can't have nested foreach() loops? This: int thoseNumbers[] = array(0, 1, 2); int otherNumbers[] = array(3, 4, 5); foreach(int this; thoseNumbers) { foreach(int other; otherNumbers) { } } throws this:Declaration of variable '__impl_foreach_index' shadows a previous declaration at line FOOwarning.WTF? Happy rainy day! Edited September 26, 2015 by fântastîque Mântragorîè Quote Link to comment Share on other sites More sharing options...
anim Posted September 26, 2015 Share Posted September 26, 2015 I remember having the same problem and it's probably a bug worth submitting, which sadly I didn't at the time I ended up using good old for, but please submit a bug int thoseNumbers[] = array(0, 1, 2); int otherNumbers[] = array(3, 4, 5); foreach(int this; thoseNumbers) { for(int i=0;i<len(otherNumbers);i++) { int other = otherNumbers[i]; } } Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted September 26, 2015 Share Posted September 26, 2015 (edited) Submitted. Edited September 26, 2015 by fântastîque Mântragorîè Quote Link to comment Share on other sites More sharing options...
fathom Posted September 26, 2015 Share Posted September 26, 2015 interesting. i wonder what the byte code for a foreach looks like. is it just a glorified macro for a for loop? that error kind of implies that it is with a hardcoded index variable. Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted September 27, 2015 Share Posted September 27, 2015 Ticket: #29899 Should be fixed in H15. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.