Jump to content
Sign in to follow this  
Guest mantragora

Shadows over loops

Recommended Posts

Guest mantragora

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 FOO

warning.

WTF?

Happy rainy day!

Edited by fântastîque Mântragorîè

Share this post


Link to post
Share on other sites

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];
    }
}

Share this post


Link to post
Share on other sites
Guest mantragora

Submitted.

Edited by fântastîque Mântragorîè

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×