www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20412] New: std.range.put misbehaves when

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

          Issue ID: 20412
           Summary: std.range.put misbehaves when OutputRange.put(void[]
                    exists)
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: eyal weka.io

Here's a reproduction of the bug:

struct OutputRange {
    void put(const(void)[] bytes) {
        import std.stdio;
        writeln(bytes);
    }
}

unittest {
    import std.range: put;
    OutputRange rng;
    put(rng, "Hello");          // Writes [72, 101, 108, 108, 111] as expected

    import std.algorithm: map;
    put(rng, "Hello".map!((dchar a)=>a)); // Writes the bytes internally
representing the MapResult: [5, 0, 0, 0, 0, 0, 0, 0, 82, 175, 72, 34, 59, 86,
0, 0]
}

--
Nov 21 2019