import conflicts

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jan 18 17:52:58 PST 2015


On 1/19/2015 4:37 AM, AndyC wrote:
> On Sunday, 18 January 2015 at 19:20:34 UTC, Vlad Levenfeld wrote:
>> I get this all the time with std.array.array (I use my own array
>> implementations, but phobos' array seems to secretly creep in
>> everywhere). I think its got to do with that private import visibility
>> bug (https://issues.dlang.org/show_bug.cgi?id=314 or
>> https://issues.dlang.org/show_bug.cgi?id=13096 I think)
>> which, by the looks of it, should be getting a fix... soon? ish?
>
> Ah, if its just a compiler bug I'm ok with that.  I was worried there
> was something about the language I didnt understand.
>
> I got it to compile ok using:
>
> import std.file: remove, exists, rename;
>
> Thanks,
>
> -Andy

The problem is, that's the bug Vlad was talking about. Selective imports 
wind up becoming public, polluting the namespace. The thing to do when 
you get conflicts is to use the fully-qualified function name, like so:

std.file.remove( "lastUpdate.7z" );

Keep those selective imports out of module scope until the bug is fixed. 
They work in local scope just fine:

void foo() {
     import std.file : remove, exists;
     if( exists( "foo" )) remove( "foo" );
}


More information about the Digitalmars-d-learn mailing list