← Back to index
|
Original Bugzilla link
Bug 18751 – chunkBy predicate cannot access local variable
Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-04-09T23:57:56Z
Last change time
2024-12-13T18:58:18Z
Assigned to
No Owner
Creator
hsteoh
See also
https://issues.dlang.org/show_bug.cgi?id=14909
,
https://issues.dlang.org/show_bug.cgi?id=18753
Moved to GitHub: dmd#19422 →
Comments
Comment #0
by hsteoh — 2018-04-09T23:57:56Z
Code: ------- unittest { import std.algorithm.comparison : equal; import std.algorithm.iteration : chunkBy; string[] data = [ "abc", "abc", "def" ]; int[] indices = [ 0, 1, 2 ]; auto chunks = indices.chunkBy!((i, j) => data[i] == data[j]); assert(chunks.equal!equal([ [ 0, 1 ], [ 2 ] ])); } ------- Compiler output: ------- /usr/src/d/phobos/std/algorithm/iteration.d(1761): Error: function test.__unittest_L9_C1.ChunkByImpl!(__lambda1, int[]).ChunkByImpl.Group.popFront cannot access frame of function test.__unittest_L9_C1 /usr/src/d/phobos/std/range/primitives.d(884): Error: template instance `std.range.primitives.isInputRange!(Group)` error instantiating /usr/src/d/phobos/std/algorithm/iteration.d(1781): instantiated from here: isForwardRange!(Group) -------
Comment #1
by hsteoh — 2018-04-10T00:04:55Z
https://github.com/dlang/phobos/pull/6441
Comment #2
by hsteoh — 2018-04-10T00:06:57Z
This is related to issue #14909, but the PR only fixes this problem, not that one, so I'm keeping the bug reports separate for now.
Comment #3
by hsteoh — 2018-04-11T21:53:22Z
PR has been closed, as it has been decided this needs to be addressed in the compiler rather than the library.
Comment #4
by robert.schadek — 2024-12-13T18:58:18Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/dmd/issues/19422
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB