www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19229] New: formattedWrite destructively iterates over

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

          Issue ID: 19229
           Summary: formattedWrite destructively iterates over forward
                    ranges
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

unittest {
    import std.conv;
    import std.algorithm;
    auto a = [sort([1,2,3])];
    assert(text(a) == text(a));
}

The above assert triggers. The issue is std.format.formatRange destructively
iterates over a[i], leaving an exhausted range behind.

std.format.formatRange or its callers need to be made aware of isForwardRange.

--
Sep 06 2018