On Monday, 21 September 2015 at 13:03:20 UTC, default0 wrote:
On Monday, 21 September 2015 at 00:01:01 UTC, Temtaime wrote:
I also hate errors when a lambda contains some errors.
[ 1 ].countUntil!(a => a == undeclared_something);
Error: template std.algorithm.searching.countUntil cannot
deduce function from argument types !((a) => a ==
undefined)(int[])
I agree, the error should contain better reasoning as to why
the function cannot be deduced. Since Phobos uses templates
pretty heavily, and sometimes has a decent set of
pre-conditions, tracking down which condition exactly is
failing is hard. Printing the template condition and the
expression in it that caused the instantiation to fail would be
tremendously helpful!
The problem is that the compiler doesn't know which version of
the template constraints you meant to invoke.
e.g.
void foo(Bar)(Bar b) if (isSomething!Bar) { ... }
and
void foo(Bar)(Bar b) if (isSomethingElse!Bar) { ... }
The best thing the compiler can do is say `Error: Bar !=
isSomething and Bar != isSomethingElse`. Which is basically what
its doing right now.