local import hijacking

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Jan 14 08:10:29 PST 2016


On 01/14/2016 09:36 AM, Daniel Kozak via Digitalmars-d wrote:
> V Thu, 14 Jan 2016 14:25:43 +0000
> Byron Heads via Digitalmars-d <digitalmars-d at puremagic.com> napsáno:
>
>> I got burned by this yesterday, this code should not compile
>>
>> import std.experimental.logger : trace;
>>
>>
>> void foo() {
>> 	import std.net.curl : trace;
>> 	trace("hello");
>> }
>>
>>
>> void main() {
>> 	foo();	
>> }
>>
>>
>> Not sure if this is a duplicate
>> https://issues.dlang.org/show_bug.cgi?id=15567
>>
>>
>>
>
> No this is OK, there is no reason to not compile.
>
> It is same as:
> import std.stdio;
>
> string trace = "trace";
> void foo() {
>      int trace = 7;
>      writeln(trace);
> }
> void main() {
>      foo();	
>      writeln(trace);
> }
>
>
> local symbols can hide global symbols

Correct. The implicitly introduced locals are the problem. Can anyone on 
the compiler team work on this? -- Andrei



More information about the Digitalmars-d mailing list