Thread overview
[Issue 12086] std.algorithm.remove + range of indices produces wrong results
Jun 11, 2014
safety0ff.bugz
Jun 13, 2014
safety0ff.bugz
Feb 10, 2018
Seb
June 11, 2014
https://issues.dlang.org/show_bug.cgi?id=12086

safety0ff.bugz <safety0ff.bugz@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz@gmail.com

--- Comment #1 from safety0ff.bugz <safety0ff.bugz@gmail.com> ---
I think this is a combination of a documentation bug and a remove bug:
The documentation bug is that it should accept any range of indices with length
1 or 2.
Currently it is only documented that tuples of length 2 should be accepted, but
I don't see why tuples should be special.

Secondly:
import std.stdio, std.algorithm;

void main(string[] args)
{
    writeln( [0,1,2,3,4].remove(1, 3) );
    // 0, 2, 4  -- correct

    writeln( [0,1,2,3,4].remove([1, 3]) );
    // 0, 3, 4  -- correct

    writeln( [0,1,2,3,4].remove(tuple(1,3)) );
    // 0, 3, 4  -- correct

    writeln( [0,1,2,3,4].remove([1,3,4]) ); // should error on invalid args
    // 0, 3, 4  -- incorrect


    writeln( [0,1,2,3,4].remove(tuple(1,3,4)) ); // should error on invalid
args
    // 0, 3, 4  -- incorrect
}

--
June 13, 2014
https://issues.dlang.org/show_bug.cgi?id=12086

--- Comment #2 from safety0ff.bugz <safety0ff.bugz@gmail.com> ---
(In reply to safety0ff.bugz from comment #1)
> I think this is a combination of a documentation bug and a remove bug:
> The documentation bug is that it should accept any range of indices with
> length 1 or 2.
> Currently it is only documented that tuples of length 2 should be accepted,
> but I don't see why tuples should be special.

Reflecting about this I realised that it is error prone, so tuples should be
the only way to specify a range of indices.
I think to fix this a relatively short deprecation cycle should be introduced
to avoid breaking code.

--
February 10, 2018
https://issues.dlang.org/show_bug.cgi?id=12086

Seb <greensunny12@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |greensunny12@gmail.com

--- Comment #3 from Seb <greensunny12@gmail.com> ---
PR https://github.com/dlang/phobos/pull/6154

--
June 13, 2018
https://issues.dlang.org/show_bug.cgi?id=12086

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/622c5d209820194651a8acb01fabc03041cd8e9e Fix Issue 12086 - std.algorithm.remove + range of indices produces wrong results

https://github.com/dlang/phobos/commit/89c1f1af6f29500013c465cc53f12e1ec6221523 Merge pull request #6154 from wilzbach/fix-12086

Fix Issue 12086 - std.algorithm.remove + range of indices produces wrong
results
merged-on-behalf-of: Nathan Sashihara <n8sh@users.noreply.github.com>

--