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

          Issue ID: 15077
           Summary: Two structs with the same name could have a nicer
                    error message
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Consider a case with two modules that define structs with the same name. If you
try to assign variables of the two types to each other, the compiler will say
something like:

f.d(12): Error: cannot implicitly convert expression (white()) of type Color to
Color 

I mentioned this in a SO answer today:
http://stackoverflow.com/questions/32615733/struct-composition-with-mixin-and-templates/32621854#32621854

you can borrow code from there but it is trivial to make another one.



Anyway, I propose the compiler error message to get a little smarter. The
current behavior is nice in most cases, a fully-qualifed name often makes error
messages long and ugly, but if the error message is ever in the form of `cannot
convert A to A`, it should print the fully qualified name so it makes sense.

So actually do a string comparison when building the message and
if(typeA.toChars() == typeB.toChars()) use_fully_qualified_name.

--

Reply via email to