Bug 604 – static, renamed, and selective imports aren't private
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-26T09:19:00Z
Last change time
2014-02-15T13:21:10Z
Assigned to
bugzilla
Creator
wbaxter
Comments
Comment #0 by wbaxter — 2006-11-26T09:19:37Z
The spec isn't specific about what should happen in this case, but I think the behavior is not what one would expect and is undesirable.
Basic imports are now private by default, so import std.stdio in one file A doesn't mean writefln will be accessible in file B that imports A. However if you switch from "import std.stdio" to "import io = std.stdio" then B will be able to access io.writefln. Similar situation with selective and static imports. None of them act private, and sticking an extra 'private' in front of the import statement doesn't change anything.
Here's an example:
-------- modulefoo.d -----------
module modulefoo;
static import std.string;
import stdio = std.stdio;
import std.stdio : writef;
--------- modulebar.d ------------
module modulebar;
import modulefoo;
void main()
{
stdio.writefln("This shouldn't work");
std.stdio.writefln("Don't think this should either");
stdio.writefln( std.string.format("This is odd too") );
writef( "This doesn't seem like it should work either\n");
}
--------------
"dmd -run modulebar" generates no errors at all.