http://d.puremagic.com/issues/show_bug.cgi?id=4816
Summary: template constraint and __traits(compiles, ...) don't work properly together with a delegate Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: jmdavisp...@gmail.com --- Comment #0 from Jonathan M Davis <jmdavisp...@gmail.com> 2010-09-05 00:42:07 PDT --- The following refuses to compile import std.stdio; void callFunc(alias func, T...)(T args) if(__traits(compiles, func(args))) { func(args); } void main() { auto func = (){writeln(4);}; callFunc!(func)(); } Rather, it gives you the error message d.d(12): Error: template d.callFunc(alias func,T...) if (__traits(compiles,func(args))) does not match any function template declaration d.d(12): Error: template d.callFunc(alias func,T...) if (__traits(compiles,func(args))) cannot deduce template function from argument types !(func)() d.d(12): Error: template instance errors instantiating template If I remove the template constraint, then it compiles fine. If I declare func as a nested function and pass that, it works fine. If I use __traits(compiles, func()) in main(), it returns true. However, the template constraint fails as long as you pass it a delegate. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------