www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13683] New: More precise error message for wrong lambda

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

          Issue ID: 13683
           Summary: More precise error message for wrong lambda
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

This is wrong code:

class Foo {}
void main() {
    import std.algorithm: all;
    Foo[] data;
    assert(data.all!(f => f != null));
}


DMD 2.067alpha gives:

test.d(5,16): Error: template std.algorithm.all cannot deduce function from
argument types !((f) => f != null)(Foo[]), candidates are:
..\dmd2\src\phobos\std\algorithm.d(12251,1):        std.algorithm.all(alias
pred = "a")


The correct code needs "!is" instead of "!=":

assert(data.all!(f => f !is null));


The error message should tell me more precisely what's the problem.

--
Nov 04 2014