local import hijacking
Daniel Kozak via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jan 14 06:36:23 PST 2016
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
More information about the Digitalmars-d
mailing list