Bug 18092 – Can't combine take and takeExactly

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-17T03:12:46Z
Last change time
2017-12-20T16:11:17Z
Assigned to
Seb
Creator
Seb

Comments

Comment #0 by greensunny12 — 2017-12-17T03:12:46Z
``` unittest { import std.algorithm.comparison : equal; import std.internal.test.dummyrange : AllDummyRanges; import std.meta : AliasSeq, Filter; static foreach (Range; Filter!(isForwardRange, AliasSeq!AllDummyRanges)) {{ Range r; assert(r.take(6).takeExactly.equal!equal( [[1, 2, 3, 4]] )); }} } ``` Errors: range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)0, cast(Length)0, cast(RangeType)1, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)0, cast(Length)0, cast(RangeType)2, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(DummyRange!(cast(ReturnBy)0, cast(Length)0, cast(RangeType)3, uint[])), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)1, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)2, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)1, cast(Length)0, cast(RangeType)1, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)1, cast(Length)0, cast(RangeType)2, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(DummyRange!(cast(ReturnBy)1, cast(Length)0, cast(RangeType)3, uint[])), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)1, cast(Length)1, cast(RangeType)1, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2446): Error: template std.range.takeExactly cannot deduce function from argument types !()(Take!(DummyRange!(cast(ReturnBy)1, cast(Length)1, cast(RangeType)2, uint[]))), candidates are: range/package.d(2358): std.range.takeExactly(R)(R range, size_t n) if (isInputRange!R) range/package.d(2398): Error: cannot use typeof(return) inside function _takeExactly_Result_asTake with inferred return type range/package.d(2481): Error: template instance std.range.takeExactly!(FilterResult!(unaryFun, int[])) error instantiating range/package.d(2398): Error: cannot use typeof(return) inside function _takeExactly_Result_asTake with inferred return type range/package.d(2526): Error: template instance std.range.takeExactly!(DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)1, uint[])) error instantiating range/package.d(2398): Error: cannot use typeof(return) inside function _takeExactly_Result_asTake with inferred return type range/package.d(2526): Error: template instance std.range.takeExactly!(DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)2, uint[])) error instantiating range/package.d(2398): Error: cannot use typeof(return) inside function _takeExactly_Result_asTake with inferred return type
Comment #1 by greensunny12 — 2017-12-17T03:40:51Z
Sorry just for posterity, the code sample should be: ``` import std.algorithm.comparison : equal; import std.internal.test.dummyrange; alias Range = DummyRange!(ReturnBy.Reference, Length.No, RangeType.Forward); Range r; assert(r.take(6).takeExactly(2).equal([1, 2])); ``` with the following error message: range/package.d(2399): Error: cannot implicitly convert expression this._input of type Take!(DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)1, uint[])) to DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)1, uint[]) range/package.d(2564): Error: template instance std.range.takeExactly!(Take!(DummyRange!(cast(ReturnBy)0, cast(Length)1, cast(RangeType)1, uint[]))) error instantiating
Comment #2 by github-bugzilla — 2017-12-18T08:14:41Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/058fdd8ebb5d0fa49664414efb9156bfbf68f2fa Fix Issue 18092 - Can't combine take and takeExactly https://github.com/dlang/phobos/commit/072e3211aef6ade35793e8cb45d721d91cdee6ef Merge pull request #5935 from wilzbach/fix-18092 Fix Issue 18092 - takeExactly cannot deduce function from generic forward range merged-on-behalf-of: Petar Kirov <[email protected]>
Comment #3 by github-bugzilla — 2017-12-18T22:57:40Z
Commits pushed to stable at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/058fdd8ebb5d0fa49664414efb9156bfbf68f2fa Fix Issue 18092 - Can't combine take and takeExactly https://github.com/dlang/phobos/commit/072e3211aef6ade35793e8cb45d721d91cdee6ef Merge pull request #5935 from wilzbach/fix-18092
Comment #4 by github-bugzilla — 2017-12-20T16:11:17Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/1ad40c6077bcd003062b5729072c139a91a87158 Fix Issue 18092 - Can't combine take and takeExactly https://github.com/dlang/phobos/commit/b712abcae24ada54ee2b4b48f64f8c2ae600a81e Fix Issue 18092 - Can't combine take and takeExactly