[Issue 7491] New: import symbol name unavailable in class scope

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 12 19:19:45 PST 2012


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

           Summary: import symbol name unavailable in class scope
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dawg at dawgfoto.de


--- Comment #0 from dawg at dawgfoto.de 2012-02-12 19:19:44 PST ---
struct S
{
    private import std.stdio;
}

class Base
{
    private import std.stdio;
}

class Derived : Base
{
    static void print()
    {
        std.stdio.writeln("Derived");
    }
}

void main()
{
    S.std.stdio.writeln("S");
    // Error: Base.std is not a declaration
    Base.std.stdio.writeln("Base");
    // Error: Derived.std is not a declaration
    Derived.std.stdio.writeln("Derived");

    Derived.print();
}

---------

Solution would be to add the disabled code.
https://github.com/D-Programming-Language/dmd/commit/4bce0eb3acbb9ecce5988c55281aa1b3fd5a42f0#L0R7832

----
This is problematic in the following case.
----
module a;

class Base
{
    private import std.algorithm;
}

----
module b;
import a, std.stdio;

class Derived : Base
{
    void foo()
    {
        // 'std' is looked up through Base.std rather than through module level
        // but Derived has no access right to the private import.
        std.stdio.writeln("Derived");
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list