www.digitalmars.com         C & C++   DMDScript  

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

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

          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:

source\app.d(9): 
Error: template std.algorithm.canFind cannot deduce function
from argument types !((a) => a.bar)(A[]), candidates are:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(11266):       
std.algorithm.canFind(alias pred = "a == b")

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

--
Feb 23 2015