April 20, 2023
https://issues.dlang.org/show_bug.cgi?id=23847

          Issue ID: 23847
           Summary: Error with regards to lambda function is confusing
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: razvan.nitu1305@gmail.com

void main()
{
    immutable int c;
    int function(int x) func;
    func = x => c;
}

(13): Error: function `main.__lambda3(__T1)(x)` cannot access variable `c` in
frame of function `D main`

There are 2 problems:

1. __lambda3 is a compiler generated identifier that should not see the light of a screen.

2. the compiler say `function` but what it outputs is actually a template declaration.

A better error message would look like: "Error: lambda function: `x => c` cannot access variable `c` in frame of function main.

--