Comment #0 by safety0ff.bugz — 2014-06-11T15:03:13Z
Trying to remove anything but the a single element from the front of a multidimensional array will cause a run time error.
This causes bugs in phobos functions who depend on remove such as replaceInPlace.
Code:
import std.typecons;
import std.algorithm;
import std.stdio : writeln;
void main()
{
// note: dimension doesn't matter
int[1][] arr = [[0], [1], [2], [3], [4], [5], [6]];
size_t from = 1; // from is inclusive
size_t to = 2; // to is exclusive
//arr = remove(arr, tuple(from,to)); // object.Error: overlapping array copy
//foreach (i; from .. to) arr = remove(arr, i); // object.Error: overlapping array copy
arr = remove(arr, 0); // Ok!
//arr = remove(arr, 1); // object.Error: overlapping array copy
// even removing nothing is broken:
//arr = remove(arr, tuple(0,0)); // object.Error: overlapping array copy
writeln(arr);
}
Comment #1 by safety0ff.bugz — 2014-06-11T15:04:51Z
(In reply to safety0ff.bugz from comment #0)
> Trying to remove anything but the a single element from the front of a
> multidimensional array will cause a run time error.
I obviously meant array of arrays instead of multidimensional.
Comment #2 by safety0ff.bugz — 2014-06-11T22:13:03Z