Bug 22000 – Identical candidates shown when templates differ by template constraints

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-07T03:54:16Z
Last change time
2024-12-13T19:16:48Z
Keywords
diagnostic
Assigned to
No Owner
Creator
mipri
Moved to GitHub: dmd#19939 →

Comments

Comment #0 by mipri — 2021-06-07T03:54:16Z
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
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19939 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB