[Issue 17653] New: Redefining symbol in separate but identical template namespaces is completely ignored

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 14 13:39:05 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17653

          Issue ID: 17653
           Summary: Redefining symbol in separate but identical template
                    namespaces is completely ignored
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

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.

--


More information about the Digitalmars-d-bugs mailing list