chunkBy bug?

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Sep 5 04:10:58 UTC 2020


On Sat, Sep 05, 2020 at 03:30:33AM +0000, JG via Digitalmars-d wrote:
> The following code won't compile:
> ----
> import std.algorithm;
> import std.range;
> import std.stdio;
> 
> void main() {
>  auto v = [2,4,8,3,6,9,1,5,7];
>  foreach(i; 2..4) {
>   writeln(v.myChunkBy!((a,b)=>a%i==b%i));
>  }
> }
> ----
> /opt/local/include/phobos/std/algorithm/iteration.d(2009): Error: function
> tmp.main.ChunkByImpl!(__lambda1, int[]).ChunkByImpl.Group.popFront cannot
> access frame of function D main
> ----
[...]

Are you using LDC?  IIRC there was a recent bug fixed in dmd that fixes
this problem in some cases, but LDC still has this bug.  Maybe try with
dmd to see if it works?


--T


More information about the Digitalmars-d mailing list