[Issue 17756] New: Ambiguous import form introduces names into the global namespace
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Aug 16 04:31:38 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17756
Issue ID: 17756
Summary: Ambiguous import form introduces names into the global
namespace
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dlang at ryanjframe.com
I was testing an import as written at [1], which is not a documented form[2],
and discovered that such imports introduce names into the global namespace:
```
void main() {
//import io = std.stdio; // Error.
import io = std.stdio : writeln; // Executes.
writeln("test");
}
```
It appears that `import io = std.stdio : writeln;` is being interpreted as
`import io = std.stdio : writeln=writeln;`. If this is the case, should an
implicit `name=name` be allowed?
```
void main() {
import io = std.stdio : writeln; // This builds and runs.
writeln("test"); // Executes.
//write("test"); // Error.
io.writeln("test"); // Executes.
io.write("test"); // Executes.
}
```
[1]: http://forum.dlang.org/post/hzfvmkrkguqbltmocfeo@forum.dlang.org
[2]: Sections 4.6 - 4.8: https://dlang.org/spec/module.html#renamed_imports
--
More information about the Digitalmars-d-bugs
mailing list