chunkBy bug?
Seb
seb at wilzba.ch
Sun Sep 6 17:08:06 UTC 2020
On Saturday, 5 September 2020 at 03:30:33 UTC, JG 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
> ----
>
> Is this expected behavior?
No.
> I can get it to run as expected by modifying the source of
> chunkBy as follows:
It's hard to read this and compare against the original
implementation here.
If this issue still persists with master, why don't you simply
open a PR for Phobos?
Bug fixes are always welcome!
More information about the Digitalmars-d
mailing list