[Issue 604] New: static, renamed, and selective imports aren't private

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 26 07:19:43 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=604

           Summary: static, renamed, and selective imports aren't private
           Product: D
           Version: 0.175
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


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.


-- 




More information about the Digitalmars-d-bugs mailing list