www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14217] New: Misleading error message: Cannot deduce function


          Issue ID: 14217
           Summary: Misleading error message: Cannot deduce function
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andre s-e-a-p.de

The following source code doesn't compile because in the lambda 'a.bar' is
written instead of 'a.foo'.

import std.algorithm: canFind;

struct A { string foo; }

void main()
    A[] arr;
    arr.canFind!(a => a.bar);

It isn't clear from the error message, that the property'bar' is causing the

Error: template std.algorithm.canFind cannot deduce function
from argument types !((a) => a.bar)(A[]), candidates are:
std.algorithm.canFind(alias pred = "a == b")

I would expect an error message: no property 'bar' for type 'A'

Feb 23 2015