digitalmars.D.bugs - [Issue 9179] New: Invalid template instantiation attempt should result in a readable error message
- d-bugmail puremagic.com (50/50) Dec 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=9179
http://d.puremagic.com/issues/show_bug.cgi?id=9179 Summary: Invalid template instantiation attempt should result in a readable error message Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com --- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-18 09:44:19 PST --- template Pred(T) { enum Pred = true; } void func(T)(T t) if (Pred(T)) { } void main() { func(1); } Errors: test.d(9): Error: template test.Pred does not match any function template declaration. Candidates are: test.d(3): test.Pred(T) test.d(9): Error: template test.Pred(T) cannot deduce template function from argument types !()(int) test.d(15): Error: template test.func does not match any function template declaration. Candidates are: test.d(8): test.func(T)(T t) if (Pred(T)) test.d(15): Error: template test.func(T)(T t) if (Pred(T)) cannot deduce template function from argument types !()(int) The problem is Pred was used as a function instead of as a template, the fix is: void func(T)(T t) if (Pred!(T)) // note the !() syntax { } There is no other way the Pred template can be called because it's not a function template, therefore we should print out a better error message such as: test.d(9): Error: Need to use !() syntax to instantiate template test.Pred -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 18 2012