February 14, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Local imports hide local    |Prevent local imports from
                   |symbols                     |hiding local symbols
           Severity|critical                    |enhancement

--
February 14, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #23 from Walter Bright <bugzilla@digitalmars.com> ---
Since this was working as designed, I reclassified it as an enhancement request.

--
February 16, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #24 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e5be0735919ce89dca7488e72229823d4a221773 fix Issue 10378 - Local imports hide local symbols

https://github.com/D-Programming-Language/dmd/commit/57592cf2c52460d8d5dfc74e5c02d6afb7bc6c33 Merge pull request #5445 from WalterBright/fix10378-2

fix Issue 10378 - Local imports hide local symbols

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #25 from hsteoh@quickfur.ath.cx ---
Woohoo! Finally this bug is fixed! Big thanks to Walter for doing this.

Now looking forward to the fixes for issues #313 and #314 as well...

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #26 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
but they are... long time ago: https://github.com/D-Programming-Language/dmd/pull/3416

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #27 from hsteoh@quickfur.ath.cx ---
In the discussion on the PR for this bug, #313 and #314 were mentioned as primary candidates to be fixed in the next compiler release. I think it makes sense to fix these module-related bugs as the goal for this release, since some of them will be breaking changes, and it's better to break module-related stuff once and have it work correctly from then on, than to be forced to break code multiple times -- users would revolt.

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #28 from timon.gehr@gmx.ch ---
(In reply to hsteoh from comment #25)
> Woohoo! Finally this bug is fixed! Big thanks to Walter for doing this.
> 

It's probably not the best fix though. Now locally imported symbols can still hide symbols imported in a less deeply nested scope, hence hijacking is still not prevented. This can also be dangerous when refactoring a large module into smaller ones.

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #29 from hsteoh@quickfur.ath.cx ---
Do you have an example where this is problematic?

At any rate, it's better than the stonewall silence we've had on import issues for many years now.

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #30 from timon.gehr@gmx.ch ---
(In reply to hsteoh from comment #29)
> Do you have an example where this is problematic?
> 

Slightly contrived, but here you go:

import std.stdio;

string readAndLog(string filename){
    import std.file;
    auto text=readText(filename);
    write(filename," read successfully!\n");
    return text;
}

void main(){
    writeln(readAndLog("important_data.txt"));
}


> At any rate, it's better than the stonewall silence we've had on import issues for many years now.

I agree. This is way better than what we had before. If a fix for hijacking is implemented, I would personally prefer to pick a proposed solution that actually fixes the hijacking problems.

--
February 17, 2016
https://issues.dlang.org/show_bug.cgi?id=10378

--- Comment #31 from hsteoh@quickfur.ath.cx ---
Ouch. That's a pretty nasty one. I suppose it's because the inner import pulls in 'write' into a different overload set from the outer import, so the compiler doesn't complain about the ambiguity error, even though the user did not intend to call std.file.write (rather than std.stdio.write) here.

So unqualified local imports are still extremely dangerous... :-(

--