www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 140] New: Conflicting identifiers between imported modules are reported in the wrong file

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=140

           Summary: Conflicting identifiers between imported modules are
                    reported in the wrong file
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: smjg iname.com


If a module imports two modules, each of which defines the same identifier, and
then tries to use it without specifying which one, then the error is reported
as being in one of the imported modules.  This is nonsense.

----- module0.d -----
import module1;
import module2;

void main() {
        func();
}
----- module1.d -----
module module1;

void func() {}
----- module2.d -----
module module2;

void func() {}
----------
module1.d(3): function module1.func conflicts with module2.func at module2.d(3)
----------

If two libraries happen to use the same identifier, then this isn't the fault
of either library.  The compiler shouldn't be claiming that it is.

In fact, the error is in module0, where the identifier is used.  And it's the
author of module0 that needs to resolve the conflict by explicitly specifying
module1.func or module2.func.  With the current bad error message, it's an
absolute nightmare to find where the conflict needs resolving.

A suitable error message for this instance would be:
----------
module0.d(5): identifier func matches both
module1.d(3): module1.func
and
module2.d(3): module2.func
----------

Of course, it may be an overloaded function in either or both of the modules. 
The line number reported for each match might as well be where the name is
first defined.

If the conflict is between three or more modules, then the message should be
adjusted accordingly.


-- 
May 13 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-05-13:
 If a module imports two modules, each of which defines the same identifier, and
 then tries to use it without specifying which one, then the error is reported
 as being in one of the imported modules.  This is nonsense.
Added to DStress as http://dstress.kuehne.cn/nocompile/i/import_14_A.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEcNY53w+/yD4P9tIRAvdnAJ9QbNE/vxuG6IBmo+ma6qyHhLU5swCdHWYQ IZqbOhwRHSZHQ9qkTKE9CME= =o9D0 -----END PGP SIGNATURE-----
May 21 2006