www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18091] New: "Error instantiating" cumulativeFold when passing

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

          Issue ID: 18091
           Summary: "Error instantiating" cumulativeFold when passing a
                    function inside another function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: abc.mikey gmail.com

DMD64 D Compiler v2.072.1

Best see with a test case:

import std.algorithm : cumulativeFold;

struct T {}

T t1(T a, int b) {
    return T.init;
}

void main() {

    auto arr = [0,1,1,0,0,0];

    T t2(T a, int b) {
        return T.init;
    }

    auto r1 = arr.cumulativeFold!( (a,b) => T.init )( T.init ); // no error
    auto r2 = arr.cumulativeFold!t1( T.init );                  // no error
    //auto r3 = arr.cumulativeFold!t2( T.init );                // errors

}

--
Dec 16 2017