On 12/27/11 3:35 AM, bearophile wrote:
This program contains wrong syntax because x lacks a type:

void main() {
     double delegate(double) f;
     f = (x) =>  x + 1;
}


DMD gives the error messages:

test.d(3): Error: undefined identifier x, did you mean variable f?
test.d(3): Error: cannot implicitly convert expression (__dgliteral1) of type 
_error_ delegate(_error_) to double delegate(double)

Is it wise to try to improve the second error message?

Actually that's an old bug in the compiler. Lambdas without parameter types are really templates, and a template should be assignable to a function or delegate if the parameter type binding works.


Andrei


Reply via email to