www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16548] New: Shadowing a variable not detected when nesting

https://issues.dlang.org/show_bug.cgi?id=16548

          Issue ID: 16548
           Summary: Shadowing a variable not detected when nesting foreach
                    with associative arrays
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: skocznymr gmail.com

Reproduces on git HEAD.

This code:

void main()
{
    int[int] x;
    foreach (int a; x)
    {
        foreach (int a; x)
        {
        }
    }
}

should generate a compile error "variable a is shadowing variable a", but it
doesn't.

When using non-associative arrays, the error is generated properly.

--
Sep 26 2016