D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7841 - Better error message for wrong template argument with ref
Summary: Better error message for wrong template argument with ref
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2012-04-05 18:09 UTC by bearophile_hugs
Modified: 2017-06-26 17:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-04-05 18:09:49 UTC
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 Vladimir Panteleev 2017-06-26 17:38:00 UTC
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!