Created attachment 1108
Reduced testcase
I'm getting this compilation error with the attached code.
/tmp/lol.d(33): Error: template lol.lol does not match any function template
declaration
/tmp/lol.d(21): Error: template lol.lol cannot deduce template function from
argument types !(B)(OMG,void)
/tmp/lol.d(33): Error: template instance lol!(B) errors instantiating template
Comment #1 by k.hara.pg — 2012-06-02T21:13:50Z
This is not UFCS issue. Proper function call shows same errors.
In my opinion, the cause of problem is the inference of lambda parameters over partially specialized IFTI call.
----
class X {}
class A {}
class B : A {}
void foo(T : A)(X x) {}
void foo(T : A)(X x, void function (T) block) {}
void main()
{
auto x = new X;
//x.foo!B((a){}); // UFCS version shows same errors
foo!B(x, (a){});
// Error: template test.foo does not match any function template declaration
// Error: template test.foo cannot deduce template function from argument types !(B)(X,void)
// Error: template instance foo!(B) errors instantiating template
// Call explicitly aliased symbol still not good.
alias foo!B Lol;
Lol(x, (a){});
// Error: template test.foo matches more than one template declaration, test.d(5):foo(T : A) and test.d(6):foo(T : A)
// Error: function expected before (), not foo!(B) of type void
// But, avoiding lambda parameter inference stops errors.
foo!B(x);
foo!B(x, (B b){});
}
Comment #2 by k.hara.pg — 2012-06-06T04:25:11Z
*** Issue 8202 has been marked as a duplicate of this issue. ***
Comment #3 by k.hara.pg — 2012-06-06T04:29:01Z
From issue 8202:
void func(T, R)(R range, T value) {}
void main()
{
ubyte[] buffer = [0, 1, 2];
func!ushort(buffer, 915);
}
This is partially specialized template function problem.