Bug 7841 – Better error message for wrong template argument with ref
Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-05T18:09:00Z
Last change time
2017-06-26T17:38:00Z
Keywords
diagnostic
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-04-05T18:09:49Z
This is correct D2 code, and it gives no error messages:
void foo(T)(const ref T[] a) {}
void bar(in int[] b) {
foo(b);
}
void main() {}
This is wrong D2 code (I have replaced "const ref" with "ref"):
void foo(T)(ref T[] a) {}
void bar(in int[] b) {
foo(b);
}
void main() {}
DMD 2.059 gives this error message:
temp.d(1): Error: template temp.foo(T) cannot deduce template function from argument types !()(const(int[]))
In this case I'd like a better error message.
Comment #1 by dlang-bugzilla — 2017-06-26T17:38:00Z
Error message now looks like:
test.d(3,8): Error: template test.foo cannot deduce function from argument types !()(const(int[])), candidates are:
test.d(1,6): test.foo(T)(ref T[] a)
Hopefully that qualifies as an improvement!