You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code:
import std.algorithm : each;
void main()
{
auto arr = [1,2,3];arr.each!(x => writeln(x));
}
won't compile:
/d768/f609.d(8): Error: template f609.main.each!((x) => writeln(x)).each cannot deduce function from argument types !()(int[]), candidates are:
/opt/compilers/dmd2/include/std/algorithm/iteration.d(875): f609.main.each!((x) => writeln(x)).each(Range)(Range r) if (isRangeIterable!Range && !isForeachIterable!Range)
/opt/compilers/dmd2/include/std/algorithm/iteration.d(899): f609.main.each!((x) => writeln(x)).each(Iterable)(Iterable r) if (isForeachIterable!Iterable)
The real problem is that x => writeln(x) doesn't compile because you missed import std.stdio in this case. The same goes if any error exists inside lambda. But error won't give help you that much (in this case error is easy to spot)
The text was updated successfully, but these errors were encountered:
trikko (@trikko) reported this on 2016-04-07T15:56:42Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=15893
Description
This code: import std.algorithm : each; void main() { auto arr = [1,2,3]; arr.each!(x => writeln(x)); } won't compile: /d768/f609.d(8): Error: template f609.main.each!((x) => writeln(x)).each cannot deduce function from argument types !()(int[]), candidates are: /opt/compilers/dmd2/include/std/algorithm/iteration.d(875): f609.main.each!((x) => writeln(x)).each(Range)(Range r) if (isRangeIterable!Range && !isForeachIterable!Range) /opt/compilers/dmd2/include/std/algorithm/iteration.d(899): f609.main.each!((x) => writeln(x)).each(Iterable)(Iterable r) if (isForeachIterable!Iterable) The real problem is that x => writeln(x) doesn't compile because you missed import std.stdio in this case. The same goes if any error exists inside lambda. But error won't give help you that much (in this case error is easy to spot)The text was updated successfully, but these errors were encountered: