Fix issue 11576.

This commit is contained in:
H. S. Teoh 2013-11-21 19:33:47 -08:00
parent dc4bd532d0
commit c1ce350db9

View file

@ -8139,8 +8139,17 @@ if (s != SwapStrategy.stable
if (blackouts[right].pos + blackouts[right].len >= range.length)
{
range.popBackN(blackouts[right].len);
--right;
continue;
// Since right is unsigned, we must check for this case, otherwise
// we might turn it into size_t.max and the loop condition will not
// fail when it should.
if (right > 0)
{
--right;
continue;
}
else
break;
}
// Advance to next blackout on the left
assert(blackouts[left].pos >= steps);
@ -8266,6 +8275,14 @@ unittest
== [0, 9, 8, 7, 4, 5]);
}
unittest
{
// Issue 11576
auto arr = [1,2,3];
arr = arr.remove!(SwapStrategy.unstable)(2);
assert(arr == [1,2]);
}
/**
Reduces the length of the bidirectional range $(D range) by removing
elements that satisfy $(D pred). If $(D s = SwapStrategy.unstable),