Issue 10378 - Local imports hide local symbols#4915
Issue 10378 - Local imports hide local symbols#49159rnsr wants to merge 4 commits intodlang:masterfrom
Conversation
e9635f8 to
d7a18c1
Compare
|
|
I have revived this pull request here: #5353 |
|
Rebased. |
|
Looks reasonable at a glance. I'll have a second look later. |
|
I want to spend some more time on this. At first glance, it seems like a lot of code just to add a check. |
It's a special scope for the function local imports.
By the rewriting, a symbol shadowing by local imports will become equivalent with the shadowing by WithStatement.
|
This PR deals with shadowing of local symbols within a function. It does not deal with shadowing when using an import in, say, a class declaration. For example: fails to compile. |
|
I'm working on fixing this, so please, no overlapping efforts! |
The concept of this PR is, a symbol shadowing introduced by local imports, are essentially equivalent with the shadowing done by WithStatement. I think that using same mechanism for the two would increase language consistency. |
In the example code, the import declaration is not local, it's in struct member scope (it affects all other member functions, if declared). So it's beyond the target of this PR. |
|
I understand. But this case is one of the things people complained about. I'm working on a fix that will address all cases of doing imports inside scopes. |
|
Anyhow, the reboot based on #deadalnix 's proposed algorithm is now in #5445 |
|
Now that #5445 is merged, can this PR be closed? |
|
The tests may still be useful. |
|
Should we merge the tests then? |
|
The tests are useless anymore. |
https://issues.dlang.org/show_bug.cgi?id=10378
Reuse the symbol shadowing detection mechanism for
WithStatement.This PR is based on #4857, because the local import behavior change will hit issue 14858 in Phobos unittest.