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

Simen Kjaeraas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
            Summary|arrays confuse static       |static foreach must
                   |foreach                     |deep-copy front() per
                   |                            |iteration
                 OS|Windows                     |All

--- Comment #4 from Simen Kjaeraas <[email protected]> ---
> Everything that is not a deep copy is plainly wrong.

It seems you're right. I though this code would cause problems, but it's
statically disallowed:

static foreach (e; S()) {
    // Change an element that will also be present in the next iteration.
    e[0]++; // Error: cannot modify constant 2
    writeln(e);
}

If the above would compile, it'd be a clear issue. However, it doesn't, so it
seems a deep copy should indeed work.

--

Reply via email to