Bug 16588 – uniq's BidirectionalRange behavior is inconsistent with its InputRange behavior

Status
REOPENED
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-03T23:24:49Z
Last change time
2024-12-01T16:28:02Z
Keywords
industry
Assigned to
Eduard Staniloiu
Creator
Ali Cehreli
Moved to GitHub: phobos#10203 →

Comments

Comment #0 by acehreli — 2016-10-03T23:24:49Z
import std.algorithm; struct S { int i; string s; } void main() { auto arr = [ S(1, "a"), S(1, "b"), S(2, "c"), S(2, "d")]; // Let's consider just the 'i' member for equality auto r = arr.uniq!((a, b) => a.i == b.i); assert(r.equal([S(1, "a"), S(2, "c")])); // makes sense // Since there are just 2 elements, we expect the following assert(r.front == S(1, "a")); // good, consistent assert(r.back == S(2, "c")); // FAILS // Instead, the following passes but it's unexpected assert(r.back == S(2, "d")); } Bonus: uniq could take a PickStrategy template parameter so that the caller could specify which of the unique elements of each sequence to pick, either the first or the last. Ali
Comment #1 by edi33416 — 2016-12-16T16:07:43Z
Comment #2 by github-bugzilla — 2016-12-19T19:58:56Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/a502b2a254a814aaf68927d07d59baa8ba87dd8f Fix issue 16588 - uniqs BidirectionalRange behavior is inconsistent with its InputRange behavior https://github.com/dlang/phobos/commit/428217b31789a0b36fcf776467b077a5f165ef6c Merge pull request #4961 from edi33416/uniq_consistency Fix issue 16588 - uniqs BidirectionalRange behavior is inconsistent w…
Comment #3 by github-bugzilla — 2017-01-07T03:03:08Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/a502b2a254a814aaf68927d07d59baa8ba87dd8f Fix issue 16588 - uniqs BidirectionalRange behavior is inconsistent with its InputRange behavior https://github.com/dlang/phobos/commit/428217b31789a0b36fcf776467b077a5f165ef6c Merge pull request #4961 from edi33416/uniq_consistency
Comment #4 by github-bugzilla — 2017-01-16T23:25:53Z
Commits pushed to newCTFE at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/a502b2a254a814aaf68927d07d59baa8ba87dd8f Fix issue 16588 - uniqs BidirectionalRange behavior is inconsistent with its InputRange behavior https://github.com/dlang/phobos/commit/428217b31789a0b36fcf776467b077a5f165ef6c Merge pull request #4961 from edi33416/uniq_consistency
Comment #5 by dlang-bugzilla — 2017-05-10T23:56:41Z
Comment #6 by andrei — 2017-05-11T06:32:01Z
After we undid the pull, what would be an alternative fix to this?
Comment #7 by dlang-bugzilla — 2017-05-11T10:17:57Z
(In reply to Andrei Alexandrescu from comment #6) > After we undid the pull, what would be an alternative fix to this? See the discussion in the revert PR.
Comment #8 by bugzilla — 2019-12-29T10:09:57Z
Comment #9 by acehreli — 2019-12-30T09:44:10Z
berni44, your last comment contains a link back to this issue but this issue is not about recursion. ;)
Comment #10 by bugzilla — 2019-12-30T10:09:55Z
Oops, sorry. Wanted to point to https://issues.dlang.org/show_bug.cgi?id=12404
Comment #11 by robert.schadek — 2024-12-01T16:28:02Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10203 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB