[Issue 22000] New: Identical candidates shown when templates differ by template constraints
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 7 03:54:16 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22000
Issue ID: 22000
Summary: Identical candidates shown when templates differ by
template constraints
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: mipri at minimaltype.com
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
--
More information about the Digitalmars-d-bugs
mailing list