[Issue 9831] Error message with failed lambda inference

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 17 03:59:28 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=9831



--- Comment #2 from bearophile_hugs at eml.cc 2013-11-17 03:59:26 PST ---
(In reply to comment #1)
> x => c does not have a type yet, the problem is in inferring the type, not
> converting.
> 
> I'm tempted to close as invalid, but I'll leave it up to you.

Dropping the immutable annotation, this simpler program gives (dmd 2.065alpha):

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


temp.d(4): Error: cannot infer function literal type from int function(int x)


While if I copy the value of 'c' inside the lambda it compiles with no errors:


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


So I think this issue is valid, the type inferencer could become a bit smarter
and compile the first case too. But perhaps this issue should be regarded as an
Enhancement.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list