int function(int) f2; auto f1 = (int x) => x; // OK f2 = (int x) => x; // Errors void main() { f2 = (int x) => x; // OK } DMD 2.066alpha gives: test.d(3,9): Error: no identifier for declarator f2 test.d(3,9): Error: Declaration expected, not '=' Here I'd like D to give a single better error message, that explains the true problem.
The problem is that this code is violating the grammar. DMD expects a declaration but we have an expression, so it just errors out with a silly token error. I don't know if this can be properly fixed, since you have to actually parse ahead to see what you got there and if multiple errors occur, then it's hard to know where to restart parsing.