www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20268] New: anonymous function parameter mismatch errors

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

          Issue ID: 20268
           Summary: anonymous function parameter mismatch errors don't
                    include parameters
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: elpenguino+D gmail.com

As of DMD 2.088.0, the error messages for mismatching parameters provide no
hint about an anonymous function's expected parameters.

For example,
```
alias f = (x,y) => true;
auto x = f(1);
```
currently results in an error like
```
onlineapp.d(3): Error: template D main.__lambda1 cannot deduce function from
argument types !()(int), candidates are:
onlineapp.d(2):        onlineapp.main.__lambda1
```

Compare with typical functions:
```
bool f(X,Y)(X,Y) { return true; }
auto x = f(1);
```
results in
```
onlineapp.d(3): Error: template D main.f cannot deduce function from argument
types !()(int), candidates are:
onlineapp.d(2):        onlineapp.main.f(X, Y)(X, Y)
```

--
Oct 04 2019