chunkBy bug?
JG
someone at somewhere.com
Sat Sep 5 11:14:08 UTC 2020
On Saturday, 5 September 2020 at 04:10:58 UTC, H. S. Teoh wrote:
> 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
Thanks for your reply. I was getting the same error with both dmd
and ldc, I will try updating. For clarity do you know what
precisely is causing the problem? My "fix" was to un-nest the
structs used in chunkBy. Was the bug in dmd, something to do with
nested structs?
More information about the Digitalmars-d
mailing list