digitalmars.D.bugs - [Issue 18470] New: std.algorithm.splitter has frame access problems
- d-bugmail puremagic.com (67/67) Feb 19 2018 https://issues.dlang.org/show_bug.cgi?id=18470
https://issues.dlang.org/show_bug.cgi?id=18470 Issue ID: 18470 Summary: std.algorithm.splitter has frame access problems for custom preds Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: greensunny12 gmail.com This isn't an issue for the string binaryFuns as used in the examples, but their lambda variants fail: --- void main() { import std.algorithm; auto w = [[0], [1], [2]]; assert(w.splitter!"a.front == b"(1).equal([[[0]], [[2]]])); assert(w.splitter!((a, b) => a.front == b)(1).equal([[[0]], [[2]]])); // fails } --- --- onlineapp.d(8): Error: template std.algorithm.iteration.splitter cannot deduce function from argument types !((a, b) => a.front == b)(int[][], int), candidates are: /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(3695): std.algorithm.iteration.splitter(alias pred = "a == b", Range, Separator)(Range r, Separator s) if (is(typeof(binaryFun!pred(r.front, s)) : bool) && (hasSlicing!Range && hasLength!Range || isNarrowString!Range)) /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(4000): std.algorithm.iteration.splitter(alias pred = "a == b", Range, Separator)(Range r, Separator s) if (is(typeof(binaryFun!pred(r.front, s.front)) : bool) && (hasSlicing!Range || isNarrowString!Range) && isForwardRange!Separator && (hasLength!Separator || isNarrowString!Separator)) /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(4264): std.algorithm.iteration.splitter(alias isTerminator, Range)(Range input) if (isForwardRange!Range && is(typeof(unaryFun!isTerminator(input.front)))) /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(4510): std.algorithm.iteration.splitter(C)(C[] s) if (isSomeChar!C) ---- --- void main() { import std.algorithm; import std.ascii : toLower; assert("abXcdxef".splitter!"a.toLower == b"('x').equal(["ab", "cd", "ef"])); assert("abXcdxef".splitter!((a, b) => a.toLower == b)('x').equal(["ab", "cd", "ef"])); } --- --- /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(3726): Error: static function onlineapp.main.splitter!((a, b) => a.toLower == b, string, char).splitter.Result.lastIndexOf cannot access frame of function D main /dlang/dmd/linux/bin64/../../src/phobos/std/algorithm/iteration.d(3764): Error: function onlineapp.main.splitter!((a, b) => a.toLower == b, string, char).splitter.Result.front cannot access frame of function D main onlineapp.d(8): Error: template instance onlineapp.main.splitter!((a, b) => a.toLower == b, string, char) error instantiating --- --
Feb 19 2018