Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7760 from RazvanN7/Issue_17630
Fix Issue 17630 - selective imports find symbols in private imports o… merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Fix Issue 17630 - selective imports find symbols in private imports of other modules | ||
|
||
Selectively importing a symbol should work only if the symbol | ||
imported is defined or publicly imported in the imported module. | ||
Due to a compiler bug, selectively importing a symbol works even | ||
if the symbol is defined in a privately imported module in the | ||
imported module. | ||
----------------------------------------------------------- | ||
//a.d | ||
int bar; | ||
|
||
//b.d | ||
import a; | ||
|
||
//c.d | ||
import b : bar; | ||
------------------------------------------------------------ | ||
The above code will now result in a deprecation message | ||
which states that `bar` cannot be accessed since it is | ||
privately imported in `b`. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// REQUIRED_ARGS: -de | ||
// EXTRA_SOURCES: imports/b17630.d | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail17630.d(12): Deprecation: Symbol `Erase` is not visible because it is privately imported | ||
--- | ||
*/ | ||
|
||
void main() | ||
{ | ||
import imports.a17630 : Erase; | ||
assert(Erase == 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module a17630; | ||
|
||
import b17630; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module b17630; | ||
|
||
int Erase; |