www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14984] New: Make it illegal (or at least a warning) to modify

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

          Issue ID: 14984
           Summary: Make it illegal (or at least a warning) to modify the
                    iteration variable in foreach
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schuetzm gmx.net

Modifying the index variable in `foreach` is almost always wrong, for example:

https://github.com/D-Programming-Language/dmd/pull/4991

Thus, it should be deprecated and later forbidden. If someone really wants to,
they can use a normal `for` loop.

--
Aug 30 2015