[Issue 12407] New: reduce cannot deduce argument types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 18 18:19:16 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12407

           Summary: reduce cannot deduce argument types
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: lt.infiltrator at gmail.com


--- Comment #0 from Infiltrator <lt.infiltrator at gmail.com> 2014-03-18 18:19:12 PDT ---
http://dpaste.dzfl.pl/f2d178081ee8

-----------------------------------------------------------
import std.algorithm : map, reduce;

class A {
   long fun() {
      return 1 + sub.map!(s => s.fun()).reduce!((a, b) => a + b)(0L);
   }

   A[] sub;
}

void main() { }
----------------------------------------------------------
Fails to compile:
/d414/f619.d(5): Error: template std.algorithm.reduce cannot deduce function
from argument types !((a, b) => a + b)(MapResult!(__lambda1, A[]), long),
candidates are: /opt/compilers/dmd2/include/std/algorithm.d(701):
std.algorithm.reduce(fun...) if (fun.length >= 1)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list