-
-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 313 - Fully qualified names bypass private imports
- b/c we're using a global package tree, imported modules were accessible in other scopes using fully qualified names - maintain a whitelist of imported modules in the current scope
- Loading branch information
1 parent
57592cf
commit ea25aad
Showing
24 changed files
with
216 additions
and
16 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
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
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
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,8 @@ | ||
| module imports.a313; | ||
|
|
||
| // adds private package imports | ||
| private import imports.b313; | ||
| // adds private package core | ||
| private import core.stdc.stdio; | ||
| // adds public alias cstdio | ||
| public alias cstdio = core.stdc.stdio; |
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,7 @@ | ||
| module imports.b313; | ||
|
|
||
| void bug() | ||
| { | ||
| // scope has access to it's own module | ||
| imports.b313.bug(); | ||
| } |
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,5 @@ | ||
| module imports.pkg313.c313; | ||
|
|
||
| void bug() | ||
| { | ||
| } |
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 imports.pkgmod313.mod; | ||
|
|
||
| void bar() {} |
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,5 @@ | ||
| module imports.pkgmod313; | ||
|
|
||
| public import imports.pkgmod313.mod; | ||
|
|
||
| void foo() {} |
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,26 @@ | ||
| /* | ||
| REQUIRED_ARGS: -de | ||
| */ | ||
| module test313; | ||
|
|
||
| import imports.a313; | ||
|
|
||
| void test1() | ||
| { | ||
| import imports.b313; | ||
| imports.b313.bug(); | ||
| } | ||
|
|
||
| void test2() | ||
| { | ||
| cstdio.printf(""); | ||
| } | ||
|
|
||
| import imports.pkg313.c313; | ||
| void test3() | ||
| { | ||
| imports.pkg313.c313.bug(); | ||
| } | ||
|
|
||
| // private symbols from other modules are still visible | ||
| static assert(core.stringof == "package core"); |
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,6 @@ | ||
| // REQUIRED_ARGS: -de | ||
| void test1() | ||
| { | ||
| import core.stdc.stdio; | ||
| core.stdc.stdio.printf(""); | ||
| } |
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,8 @@ | ||
| // REQUIRED_ARGS: -de | ||
| import imports.pkgmod313; | ||
|
|
||
| void test() | ||
| { | ||
| imports.pkgmod313.foo(); | ||
| imports.pkgmod313.bar(); | ||
| } |
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,9 @@ | ||
| // first imported as package | ||
| // EXTRA_SOURCES: imports/pkgmod313/mod.d | ||
| // REQUIRED_ARGS: -de | ||
| import imports.pkgmod313; // then as package module | ||
|
|
||
| void test() | ||
| { | ||
| imports.pkgmod313.foo(); | ||
| } |
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,9 @@ | ||
| // first resolved as package, then created as module (with name package) | ||
| // EXTRA_SOURCES: imports/pkgmod313/mod.d imports/pkgmod313/package.d | ||
| // REQUIRED_ARGS: -de | ||
| import imports.pkgmod313; // then imported as package module | ||
|
|
||
| void test() | ||
| { | ||
| imports.pkgmod313.foo(); | ||
| } |
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 |
|---|---|---|
| @@ -1,19 +1,24 @@ | ||
| /* | ||
| REQUIRED_ARGS: -de | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/fail313.d(15): Error: function fail313.Derived.str return type inference is not supported if may override base class function | ||
| fail_compilation/fail313.d(16): Deprecation: module imports.b313 is not accessible here | ||
| fail_compilation/fail313.d(23): Deprecation: package core.stdc is not accessible here | ||
| fail_compilation/fail313.d(23): Deprecation: module core.stdc.stdio is not accessible here | ||
| --- | ||
| */ | ||
| module test313; | ||
|
|
||
| class Base | ||
| import imports.a313; | ||
|
|
||
| void test1() | ||
| { | ||
| abstract int str(); | ||
| imports.b313.bug(); | ||
| import imports.b313; | ||
| imports.b313.bug(); | ||
| } | ||
|
|
||
| class Derived : Base | ||
| void test2() | ||
| { | ||
| override str() | ||
| { | ||
| return "string"; | ||
| } | ||
| core.stdc.stdio.printf(""); | ||
| } |
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,7 @@ | ||
| module imports.a313; | ||
|
|
||
| private import imports.b313; | ||
| private static import imports.b313; | ||
| private static import b313 = imports.b313; | ||
|
|
||
| private import core.stdc.stdio; |
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,4 @@ | ||
| module imports.b313; | ||
|
|
||
| void bug() | ||
| {} |