Bug 17405 – [module] Named module import bypass global
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-05-17T07:09:00Z
Last change time
2017-05-17T07:28:02Z
Assigned to
nobody
Creator
chalucha
Comments
Comment #0 by chalucha — 2017-05-17T07:09:36Z
Lets have:
bar.d
-----
module bar;
enum foo = "bar";
baz.d
-----
module baz;
enum foo = "baz";
app.d
-----
import std.stdio;
import bar : foo;
void main()
{
import b = baz : foo;
writeln(foo);
}
It outputs "baz" but one would expect "bar" when named import is used?.
Tested with dmd-2.074.0
Comment #1 by ketmar — 2017-05-17T07:28:02Z
what your `import b = baz : foo;` actually does is this:
1. import module baz, and rename it (the module itself!) to `b`.
2. import baz's symbols into the local scope.
what you probably wanted to do is: `import baz : b = foo;` -- this way `foo` will be renamed, not `baz`.
i'm closing this bug for now, but feel free to reopen it if i misunderstood you.