www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23422] New: uniq loses position when chained to joiner

https://issues.dlang.org/show_bug.cgi?id=23422

          Issue ID: 23422
           Summary: uniq loses position when chained to joiner
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

import std;

void main() {
    auto range = [1, 2].uniq!"true";
    auto left = range.map!"[a]".joiner.array;
    auto right = range.map!"[a]".array.joiner.array;
    writefln!"left = %s, right = %s"(left, right);
    assert(left == right);
}

left = [2], right = [1]
core.exception.AssertError onlineapp.d(8): Assertion failure

Something about the order in which joiner queries uniq makes uniq return a
different "unique" element. While this is *technically* valid behavior as
specified, it is very unexpected.

--
Oct 17 2022