Current Behavior
Consider the following program
import std;
void test1(uint id, uint __)
{
int x = 0;
}
void test2(C)(uint id)
{
int x = 0;
}
void main()
{
uint a = 0;
test1(a);
test2(a);
}
For test1, DMD gives a good error message:
onlineapp.d(16): Error: function `onlineapp.test1(uint id, uint __)` is not callable using argument types `(uint)`
onlineapp.d(16): missing argument for parameter #2: `uint __`
This tells the user exactly what's wrong. Great! On the other hand, the test2 error message isn't as helpful
onlineapp.d(17): Error: none of the overloads of template `onlineapp.test2` are callable using argument types `!()(uint)`
onlineapp.d(8): Candidate is: `test2(C)(uint id)`
Expected Behavior:
The error message should be something like
onlineapp.d(16): Error: function `onlineapp.test2(C)(uint id)` is not callable using argument types `(uint)`
onlineapp.d(16): missing argument for template parameter #1: `C`
Comment #1 by salihdb — 2022-12-24T00:00:16Z
You are right, previous version error:
Issue23576.d(22): Error: template `source.test3` cannot deduce function from argument types `!()(byte)`, candidates are:
Issue23576.d(8): `source.test3(E)(int d)`
Same codes:
void test2(C)(C d)
{
byte x = 42;
assert(d == x);
assert(is(typeof(x) : C));
}
template test3(E)
{
void test3(E d)
{
byte x = 42;
assert(d == x);
assert(is(typeof(x) : E));
}
}
void main()
{
byte a = 42;
test2(a);
test3(a);
}
Comment #2 by robert.schadek — 2024-12-13T19:26:29Z