This code
int four(T)() if (is(T == int)) { return 4; }
string four(T)() if (is(T == string)) { return "four"; }
unittest {
int f = four();
assert(four!int == 4);
assert(four!string == "four");
}
fails with this template error which offers two identical candidates:
tmpl.d(5): Error: template `tmpl.four` cannot deduce function from argument types `!()()`, candidates are:
tmpl.d(1): `four(T)()`
tmpl.d(2): `four(T)()`
If the two asserts are moved above the failing line, a more useful error is produced:
tmpl.d(7): Error: template `tmpl.four` cannot deduce function from argument types `!()()`, candidates are:
tmpl.d(1): `four(T)()`
with `T = string`
must satisfy the following constraint:
` is(T == int)`
tmpl.d(2): `four(T)()`
At a guess, this is related to the resolution of Issue 7768
Seen with DMD64 D Compiler v2.097.0
Comment #1 by robert.schadek — 2024-12-13T19:16:48Z