Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda with specified template type parameter does not work with IFTI #19339

Open
dlangBugzillaToGithub opened this issue Dec 6, 2017 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Ali Ak reported this on 2017-12-06T10:40:16Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=18037

CC List

Description

When you declare a template lambda:

immutable lambda(T) = (T n) => n * n;

and call it without an explicit type it errors with with:

lambda cannot deduce function from argument types !()(int)

auto x = lambda!int(2); // works
auto x = lambda(2); // not works

Is this a bug? - tired on dmd v2.077.1
@dlangBugzillaToGithub
Copy link
Author

schveiguy (@schveiguy) commented on 2017-12-06T15:43:47Z

Tested back to 2.070.0, which is where short lambda syntax was introduced. Still fails.

The immutable looks odd, but even with alias this doesn't work.

alias lambda(T) = (T n) => n * n;

should expand to:

template lambda(T)
{
    alias lambda = (T n) => n * n;
}

Neither of these successfully use IFTI.

However, these all work:

alias lambda = (int n) => n * n;
alias lambda = n => n * n;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant