[Issue 10378] New: Local imports hide local symbols

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 16 06:51:41 PDT 2013


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

           Summary: Local imports hide local symbols
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: peter.alexander.au at gmail.com


--- Comment #0 from Peter Alexander <peter.alexander.au at gmail.com> 2013-06-16 06:51:39 PDT ---
Imports local to a function are able to hide local symbols, which can lead to
subtle breakage when libraries change and unexpected behaviour:

void main()
{
    import std.stdio;
    string message = "Hello, world!";
    writeln(message);
}

Here, if a symbol "message" was added to std.stdio then the function would use
that message instead of the local message. This could cause subtle breakage
when users update to libraries that have added new symbols.

Local imports should behave the same as module-level imports, except the
symbols are only visible in the local scope. This prevents any sort of
unexpected behaviour without hindering the power of local imports. Ambiguous
names can always be disambiguated using full symbol qualification.

-- 
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