[Issue 16548] New: Shadowing a variable not detected when nesting foreach with associative arrays

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Sep 26 12:59:42 PDT 2016


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 at puremagic.com
          Reporter: skocznymr at 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.

--


More information about the Digitalmars-d-bugs mailing list