Possibile import problem
    Bill Baxter 
    dnewsgroup at billbaxter.com
       
    Mon Dec 17 15:42:01 PST 2007
    
    
  
bearophile wrote:
> This is a problem I have found, it requires 3 source files, called test.d, a.d, b.d.
> 
> ---------------
> 
> The a.d module:
> 
> import std.string: join;
> import std.string: join;
> 
> ---------------
> 
> The b.d module: 
> 
> import std.string: join;
> 
> ---------------
> 
> The main module is test.d:
> 
> import a, b;
> void main() {
>     join(["a"], "");
> }
> 
> ---------------
> 
> DMD v1.024 produces this:
> 
> test.d(4): Error: a.join at a.d(1) conflicts with b.join at b.d(1)
> 
> Is this a bug? Aren't names qualified imports private too? And if not, why?
Yes, they should be private.  The fact that they aren't is a bug.  One 
of these:
    http://d.puremagic.com/issues/show_bug.cgi?id=313
    http://d.puremagic.com/issues/show_bug.cgi?id=314
    http://d.puremagic.com/issues/show_bug.cgi?id=1238
    http://d.puremagic.com/issues/show_bug.cgi?id=1504
This is total guess, but I suspect the reason is because selective 
imports are just a quick hack that change the import to a static import 
and then do an alias for you.
In other words I'm pretty sure this:
    import module : identifier;
generates code identical to this:
    static import module;
    alias module.identifier identifier;
I'm not sure why it wouldn't turn it into "private alias", but I think 
one of those bugs above says private aliases still conflict, so maybe it 
*is* actually turning it into a private alias.
--bb
    
    
More information about the Digitalmars-d-learn
mailing list