www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10378] New: Local imports hide local symbols

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: peter.alexander.au gmail.com


--- Comment #0 from Peter Alexander <peter.alexander.au 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: -------
Jun 16 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10378


Martin Krejcirik <mk krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |mk krej.cz
         Resolution|                            |DUPLICATE


--- Comment #1 from Martin Krejcirik <mk krej.cz> 2013-06-16 19:45:23 CEST ---
*** This issue has been marked as a duplicate of issue 7329 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10378


Peter Alexander <peter.alexander.au gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |


--- Comment #2 from Peter Alexander <peter.alexander.au gmail.com> 2013-06-16
11:44:54 PDT ---
Example was invalid, here's a better one:

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

Also, re-opening. This isn't a dupe. The other bug is just that the semantics
are undocumented, not that the behaviour is incorrect. If the current behaviour
is documented then the other bug may be closed, but this bug will still be
present, so they are not the same bug.

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