[Issue 19532] chunkBy assert error involving merge and reference ranges.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 2 10:26:35 UTC 2019


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

--- Comment #1 from Jon Degenhardt <jrdemail2000-dlang at yahoo.com> ---
This is not specific to merge. Here is an example using roundRobin. The
reference input range form fails, the value input range works fine. Only the
reference input range is shown.

----- case2.d -----
import std.stdio;
import std.range;
import std.algorithm : chunkBy;

class InputRangeClass(R)
{
    R data;
    this(R _data) pure @safe nothrow { data = _data; }
    @property bool empty() pure @safe nothrow { return data.empty; }
    @property auto front() pure @safe nothrow { return data.front; }
    void popFront() pure @safe nothrow { data.popFront(); }
}

auto inputRangeClass(R)(R range) { return new InputRangeClass!R(range); }

void main(string[] args)
{
    auto x1 = [0, 1, 3, 6];
    auto x2 = [0, 2, 4, 6, 7];
    auto x3 = [1, 2, 4, 6, 8, 8, 9];

    auto x =
        roundRobin(x1.inputRangeClass, x2.inputRangeClass, x3.inputRangeClass)
        .chunkBy!((a, b) => a == b);

    writeln(x);
}
-------------------------------

$ dmd case2.d
$ ./case2
core.exception.AssertError@/Users/jondegenhardt/devtools/dmd2-2.083.1/osx/bin/../../src/phobos/std/range/package.d(1779):
Attempting to fetch the front of an empty roundRobin
----------------
??:? _d_assert_msg [0xa7e51a2]
??:? pure nothrow @property @safe int
std.range.roundRobin!(case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass).roundRobin(case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass).Result.front() [0xa7cc5c0]
??:? pure nothrow @safe void
std.algorithm.iteration.ChunkByImpl!(case2.main(immutable(char)[][]).__lambda2,
std.range.roundRobin!(case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass).roundRobin(case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass,
case2.InputRangeClass!(int[]).InputRangeClass).Result).ChunkByImpl.popFront()
[0xa7ccc9f]

... More lines ...

??:? _Dmain [0xa7cc30f]
[[0, 0], [1], [3], [6] $

--


More information about the Digitalmars-d-bugs mailing list