Bug 17653 – Redefining symbol in separate but identical template namespaces is completely ignored
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-14T20:39:05Z
Last change time
2023-05-11T11:28:55Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Comments
Comment #0 by schveiguy — 2017-07-14T20:39:05Z
Not sure whether to mark this rejects-valid or diagnostic.
template foo(T) {
struct R { int x; }
auto foo(T t) { return R(1); }
}
template foo(T) {
struct R { string s; }
auto foo(T t, bool f) { return R("hi"); }
}
void main()
{
foo(1);
foo(1, true);
}
Error: cannot implicitly convert expression ("hi") of type string to int
It appears that the second foo is using the first foo's R to return. However, if I defined R twice in the same template it would complain. It appears that the second R is just simply ignored. That shouldn't happen.
Comment #1 by razvan.nitu1305 — 2023-05-11T11:28:55Z