digitalmars.D.bugs - [Issue 20713] New: Improve Template Deduction Error Message Given
- d-bugmail puremagic.com (60/60) Mar 31 2020 https://issues.dlang.org/show_bug.cgi?id=20713
https://issues.dlang.org/show_bug.cgi?id=20713 Issue ID: 20713 Summary: Improve Template Deduction Error Message Given Template Parameter Default Values Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: john.michael.hall gmail.com The fix for Issue 10438 means improved error messages for template constraints for functions. However, the fix does not resolve the issue for template parameter default values. Resolving Issue 10438 meant that void foo(T, U)(T t, U u) if (is(T == int) && is(U == int)) {} void main() { foo("hello", 4); } will produce the error onlineapp.d(5): Error: template onlineapp.foo cannot deduce function from argument types !()(string, int), candidates are: onlineapp.d(1): foo(T, U)(T t, U u) with T = string, U = int must satisfy the following constraint: is(T == int) However, if you modify the above code to template foo(int x = 0) { void foo(T, U)(T t, U u) if (is(T == int) && is(U == int)) {} } void main() { foo("hello", 4); } Then the error message is just onlineapp.d(12): Error: template onlineapp.foo cannot deduce function from argument types !()(string, int), candidates are: onlineapp.d(5): foo(int x = 0) Note that this is not a problem for void main() { foo!1("hello", 4); } which will produce the error onlineapp.d(8): Error: template onlineapp.foo!1.foo cannot deduce function from argument types !()(string, int), candidates are: onlineapp.d(2): foo(T, U)(T t, U u) with T = string, U = int must satisfy the following constraint: is(T == int) This indicates that the problem is with template deduction error messages with the template parameter default values. --
Mar 31 2020