[Issue 14217] New: Misleading error message: Cannot deduce function

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Feb 23 07:55:24 PST 2015


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 at puremagic.com
          Reporter: andre at 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'

--


More information about the Digitalmars-d-bugs mailing list