digitalmars.D.bugs - [Issue 19823] New: std.range.dropOne doesn't drop the element when
- d-bugmail puremagic.com (38/38) Apr 24 2019 https://issues.dlang.org/show_bug.cgi?id=19823
https://issues.dlang.org/show_bug.cgi?id=19823 Issue ID: 19823 Summary: std.range.dropOne doesn't drop the element when called after std.algorithm.iteration.filter Product: D Version: D2 Hardware: x86 OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: jonas.alves gmail.com It seems that in some cases dropOne doesn't work when called after std.algorithm.iteration.filter. In the example I'm pasting below it seems that it only works when the 1st position in the array is not filtered out. In production we had more complex cases where it would do the correct thing when compiled with dmd, but it would not work when compiled with ldc2. Anyone knows why? I didn't look at the source code, but it looks like buggy code generation. import std.range: dropOne; import std.stdio: writefln; import std.algorithm.iteration: filter; import std.array: array; void main() { auto a = [1,2,3,4]; writefln("%s", a.filter!(a => a != 1).dropOne); // [2, 3, 4] WRONG writefln("%s", a.filter!(a => a != 2).dropOne); // [3, 4] writefln("%s", a.filter!(a => a != 3).dropOne); // [2, 4] writefln("%s", a.filter!(a => a != 4).dropOne); // [2, 3] writefln("%s", a.filter!(a => a == 1).dropOne); // [] writefln("%s", a.filter!(a => a == 2).dropOne); // [2] WRONG writefln("%s", a.filter!(a => a == 3).dropOne); // [3] WRONG writefln("%s", a.filter!(a => a == 4).dropOne); // [4] WRONG writefln("%s", a.filter!(a => a != 1).array.dropOne); // [3, 4] } --
Apr 24 2019