September 18, 2020
https://issues.dlang.org/show_bug.cgi?id=21263

          Issue ID: 21263
           Summary: Improve error message for anonymous lambda
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: ali.akhtarzada@gmail.com

A lot of the time when you use anonymous templates lambdas, the errors result in identifying the lambda by their internal name (e.g. __lambda1). These lambdas usually have an identifier associated with them so why not show that identifier in the error message?

In the code:

template match(handlers...) {
 ...
 alias handlerOne = handlers[0];
 ...
 handlerOne(); // Error
}

that results in:

source/optional/match.d(28,53): Error: function literal __lambda3() is not
callable using argument types (inout(int))
source/optional/match.d(28,53):        expected 0 argument(s), not 1

Suggestion to have it result in:

Error: anonymous function __lambda3, identified as handlerOne, is not callable
using argument types (inout(int)).

--