www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18092] New: takeExactly cannot deduce function from generic

https://issues.dlang.org/show_bug.cgi?id=18092

          Issue ID: 18092
           Summary: takeExactly cannot deduce function from generic
                    forward range
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

```
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

--
Dec 16 2017