D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7201 - Lambda template assignment to variable
Summary: Lambda template assignment to variable
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2012-01-02 09:54 UTC by bearophile_hugs
Modified: 2012-01-03 11:22 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-01-02 09:54:34 UTC
In DMD 2.058head the compiler accepts a function template as argument for the foo() function:

void foo(int function(int x) g) {}
void main() {
    foo((x) => 0); // OK
}


So I think it should accept an assignment too:

void main() {
    int function(int x) f;
    f = (x) => 0; // Error
}


Currently it gives:
test.d(3): Error: __lambda4 has no value
Comment 1 Kenji Hara 2012-01-02 16:54:53 UTC
I've already post a pull to support inference on AssignExp.
https://github.com/D-Programming-Language/dmd/pull/593
Comment 2 bearophile_hugs 2012-01-03 11:22:38 UTC
Fixed, among other problems:

https://github.com/D-Programming-Language/dmd/commit/7fc5ebaf8776429fcaf38d1a55b6b25159ea9f18

See also bug 7176