www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17653] New: Redefining symbol in separate but identical


          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 puremagic.com
          Reporter: schveiguy 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, 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.

Jul 14 2017