www.digitalmars.com         C & C++   DMDScript  

D - [bug] module is in multiple packages

reply J C Calvarese <jcc7 cox.net> writes:
I found a confusing error message.  I agree I gave the compiler bad 
code; I was just hoping for a more helpful error message.

If the declared module name conflicts with the name that's requested in 
the import statement, it complains about "module x is in multiple 
packages."  I would prefer that it generated a message more like one of 
these ideas:

* main.d(3): src\helper.d(2): import statement conflicts with module 
declaration for src.helper

* src\helper.d(2): module declaration mismatched with import statement 
[main.d(3)]

* main(3): module blah.src.helper not found


When I commit this error it's a *lot* easier to fix when I understand 
what the problem is.  I will be more wary of this problem in the future, 
but a change could help others who haven't run into this before.




//---- main.d ----

import src.helper;
import src.other;

void main()
{
	something();
}




//---- src\helper.d ----

module blah.src.helper;
/* main.d(2): module helper is in multiple packages blah.src.helper */

/* Really it's a problem with the importing name conflicting
with the module declaration. */


//module src.helper;
/* The correct code works. */

const char[] whatever = "Whatever";




//---- src\other.d ----

module src.other;

import src.helper;

void something()
{
	printf("\n%.s\n\n", whatever);
}





-- 
Justin
http://jcc_7.tripod.com/d/
Jan 16 2004
parent J Anderson <REMOVEanderson badmama.com.au> writes:
J C Calvarese wrote:

 I found a confusing error message.  I agree I gave the compiler bad 
 code; I was just hoping for a more helpful error message.

 If the declared module name conflicts with the name that's requested 
 in the import statement, it complains about "module x is in multiple 
 packages."  I would prefer that it generated a message more like one 
 of these ideas:

 * main.d(3): src\helper.d(2): import statement conflicts with module 
 declaration for src.helper

 * src\helper.d(2): module declaration mismatched with import statement 
 [main.d(3)]

 * main(3): module blah.src.helper not found


 When I commit this error it's a *lot* easier to fix when I understand 
 what the problem is.  I will be more wary of this problem in the 
 future, but a change could help others who haven't run into this before.




 //---- main.d ----

 import src.helper;
 import src.other;

 void main()
 {
     something();
 }




 //---- src\helper.d ----

 module blah.src.helper;
 /* main.d(2): module helper is in multiple packages blah.src.helper */

 /* Really it's a problem with the importing name conflicting
 with the module declaration. */


 //module src.helper;
 /* The correct code works. */

 const char[] whatever = "Whatever";



 //---- src\other.d ----

 module src.other;

 import src.helper;

 void something()
 {
     printf("\n%.s\n\n", whatever);
 }
my 0.02c It would be nice if D allowed you to modify the error messages yourself. They could be listed in one error message file, using printf-line semantics. ie module %s is in multiple packages ect... or module %1 is in multiple packages You could then simply put your own error messages in. Furthermore, they could be listed on a wiki, or something and you could download updates of the list from there. Eventually, the error messages could be a load more helpful, like providing web-links with more information. I guess that could be done by the error number + IDE, but it still would be good idea to have a list of all possible error messages on the D programming page/wiki for reference purposes.
Jan 16 2004