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

--- Comment #2 from Kenji Hara <[email protected]> ---
Currently it's intentional. When you declare a index variable in foreach
statement, it works like an auto variable scoped in the foreach body.

If you need non-mutable index variable, you can write code like:

foreach (const i, v; arr) { ... }
foreach (const i; 0..len) { ... }

--

Reply via email to