www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22138] New: foreach cannot declare the loop variables as scope

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

          Issue ID: 22138
           Summary: foreach cannot declare the loop variables as scope
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

The following fails to compile:

 void test() {
    int[] a;
    foreach (scope e; a)
    {
    }
 }

but ref, enum, alias, const, immutable, shared, and inout work.

--
Jul 23 2021