Repeat and chunks

Dorian Haglund via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 24 07:25:46 PDT 2016


Hey,

The following code crashes with DMD64 D Compiler v2.071.2:

import std.algorithm;
import std.stdio;
import std.range;

int main()
{
   repeat(8, 10).chunks(3).writeln();

   return 0;
}

Error message:

pure nothrow @nogc @safe 
std.range.Take!(std.range.Repeat!(int).Repeat).Take 
std.range.Repeat!(int).Repeat.opSlice(ulong, ulong)

If I replace repeat with iota, or a literal range (like [1, 2 ,3, 
4]), I don't get the crash.

I don't see why I should not be able to use chunks with repeat.
If some property of repeat's range is missing to use chunks, 
shouldn't I get an error message ?

Am I missing something ?

PS: the behavior has been reproduced on someone else computer.

Cheers :)



More information about the Digitalmars-d-learn mailing list