[Issue 19532] chunkBy assert error involving reference input ranges.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 3 08:06:38 UTC 2019


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

--- Comment #3 from Jon Degenhardt <jrdemail2000-dlang at yahoo.com> ---
One more:

------ case4.d ------
import std.stdio;
import std.range;
import std.algorithm : chunkBy, fold, map;
import std.container.binaryheap;

void main(string[] args)
{
    auto x = [3, 1, 0, 6, 0, 2, 4, 7, 6, 8, 8, 4, 1, 2, 9, 5, 3, 1, 6];
    auto y = x
        .heapify!"a > b"
        .chunkBy!((a, b) => a == b)
        .map!(c => c.fold!((a, b) => a + b));

    writeln(y);
}
------------------------

The above will fail with assert errors similar to the others. However, the
following are fine:
   a) Removing the '.map!(c => c.fold...' line. 
   b) Adding a '.array' step after 'heapify.

The run:

$ dmd case4.d
$ ./case4
core.exception.AssertError@/Users/jondegenhardt/devtools/dmd2-2.083.1/osx/bin/../../src/phobos/std/algorithm/iteration.d(598):
Attempting to popFront an empty map.
----------------
??:? _d_assert_msg [0xc3c548e]
??:? pure @safe void
std.algorithm.iteration.MapResult!(case4.main(immutable(char)[][]).__lambda3,
std.algorithm.iteration.ChunkByImpl!(case4.main(immutable(char)[][]).__lambda2,
std.container.binaryheap.BinaryHeap!(int[], "a >
b").BinaryHeap).ChunkByImpl).MapResult.popFront() [0xc3ace89]

... more lines ...

??:? _Dmain [0xc3aa1e9]
[0, 3, 4, 6, 8, 5, 18, 7, 16, 9$

--


More information about the Digitalmars-d-bugs mailing list