Comment #0 by bearophile_hugs — 2010-07-26T13:57:48Z
This is a wrong D2 program, bar() takes as first template argument a struct template (to work it misses the commented out 'alias' at F):
struct Foo(T) {
T value;
}
F!T bar(/*alias*/ F, T)(T value) {
return F!T(value);
}
void main() {
auto b1 = bar!Foo(1); // line 8
}
dmd 2.047 prints the error messages:
test.d(8): Error: template test.bar(F,T) does not match any function template declaration
test.d(8): Error: template test.bar(F,T) cannot deduce template function from argument types !(Foo)(int)
test.d(8): Error: template instance errors instantiating template
But those error messages are too many and they don't tell what the problem is or how to fix the code. They are not helping much. If this is possible a better error message can be something like:
test.d(8): Error: in template test.bar(F,T) template template argument 'F' needs 'alias'.
Or something like:
test.d(8): Error: in template test.bar(F,T) template template argument 'Foo' passed to 'F' needs 'alias'.
Or something related.
Comment #1 by razvan.nitu1305 — 2019-12-04T11:37:02Z
The error message has improved since then:
onlineapp.d(8): Error: template onlineapp.bar cannot deduce function from argument types !(Foo)(int), candidates are:
onlineapp.d(4): bar(F, T)(T value)