www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20369] New: shadowed variable in foreach loop always

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

          Issue ID: 20369
           Summary: shadowed variable in foreach loop always considered
                    "foreach variable"
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: r.sagitario gmx.de

void foo()
{
    string[string] aa;
    string text;
    foreach(k, v; aa)
    {
       string text;
    }
}

onlineapp.d(7): Deprecation: variable text is shadowing variable
onlineapp.foo.text. Rename the foreach variable.

Note that a regular local variable is called "foreach variable".

--
Nov 08 2019