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

Simen Kjaeraas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |INVALID

--- Comment #3 from Simen Kjaeraas <[email protected]> ---
The map function changes the contents of the array, and unsurprisingly, that
changes what the filter filters. This is not a bug in filter and map, but in
your code.

Reduced example:

    auto arr = [[false]];

    writeln(arr.filter!(a =>  a[0]).map!(a => a[0] = true)); // []
    writeln(arr.filter!(a => !a[0]).map!(a => a[0] = true)); // [true]
    writeln(arr.filter!(a =>  a[0]).map!(a => a[0] = true)); // [false]

This is possibly caused by a misguided idea that the array is a value type.

--

Reply via email to