Using dmd head. template A(T...) { template B(alias T) { } } void main() { void fv() {} alias A!(fv) F; F.B!F; } t.d(8): Error: template instance B!(A!(fv)) cannot use local 'A!(fv)' as parameter to non-global template B(alias T)
I got the same problem with DMD64 D Compiler v2.063.2 on Linux Mint with the following minimal code example: struct S { void f(alias F)() { } } void main() { S.init.f!( x=>x ); // << error } I get the following error message: test.d(10): Error: template instance f!(__lambda2) cannot use local '__lambda2(__T1)(x)' as parameter to non-global template f(alias F)() The UFCS form of f works though: struct S { } void f(alias F)( S ) { } void main() { S.init.f!( x=>x ); // << works }
This is still around in DMD2.067. The UFCS trick is a nice work-around on the callee side. You can also work around it on the caller side with: struct S { void f(alias F)() { } } void main() { static int fun(int i) { return i; } S.init.f!(fun); } Both are less than ideal though.
*** This issue has been marked as a duplicate of issue 5710 ***