Skip to content

Commit

Permalink
Merge pull request #8443 from RazvanN7/checkAccess_err
Browse files Browse the repository at this point in the history
Turn deprecation into error for issue 313
merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
  • Loading branch information
dlang-bot authored Oct 25, 2018
2 parents 8542543 + aca10e8 commit 01a6a5e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
20 changes: 20 additions & 0 deletions changelog/fqn_imports_bypass_private_imports_error.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The deprecation phase for fully qualified names that bypassed private imports is finished

---
// a.d
import std.stdio;
---

---
// b.d
import a;

void main()
{
std.stdio.writefln("foo"); // deprecation before patch, now errors
}
---

In order to compile the example successfully, `public` needs to be added
to the import located in `a.d` : `public import std.stdio;` or `import std.stdio;`
needs to be added to `b.d`.
4 changes: 2 additions & 2 deletions src/dmd/access.d
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,9 @@ bool checkAccess(Loc loc, Scope* sc, Package p)
}
auto name = p.toPrettyChars();
if (p.isPkgMod == PKG.module_ || p.isModule())
deprecation(loc, "%s `%s` is not accessible here, perhaps add `static import %s;`", p.kind(), name, name);
error(loc, "%s `%s` is not accessible here, perhaps add `static import %s;`", p.kind(), name, name);
else
deprecation(loc, "%s `%s` is not accessible here", p.kind(), name);
error(loc, "%s `%s` is not accessible here", p.kind(), name);
return true;
}

Expand Down
1 change: 0 additions & 1 deletion test/compilable/testDIP37.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ void test7()
static import pkgDIP37.datetime;
static assert(!__traits(compiles, def()));
pkgDIP37.datetime.def();
pkgDIP37.datetime.common.def();
}

// https://issues.dlang.org/show_bug.cgi?id=17629
Expand Down
11 changes: 5 additions & 6 deletions test/fail_compilation/fail313.d
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*
REQUIRED_ARGS: -de
TEST_OUTPUT:
---
fail_compilation/fail313.d(18): Deprecation: module `imports.b313` is not accessible here, perhaps add `static import imports.b313;`
fail_compilation/fail313.d(25): Deprecation: `imports.a313.core` is not visible from module `test313`
fail_compilation/fail313.d(25): Deprecation: package `core.stdc` is not accessible here
fail_compilation/fail313.d(25): Deprecation: module `core.stdc.stdio` is not accessible here, perhaps add `static import core.stdc.stdio;`
fail_compilation/fail313.d(30): Deprecation: package `imports.pkg313` is not accessible here, perhaps add `static import imports.pkg313;`
fail_compilation/fail313.d(17): Error: module `imports.b313` is not accessible here, perhaps add `static import imports.b313;`
fail_compilation/fail313.d(24): Deprecation: `imports.a313.core` is not visible from module `test313`
fail_compilation/fail313.d(24): Error: package `core.stdc` is not accessible here
fail_compilation/fail313.d(24): Error: module `core.stdc.stdio` is not accessible here, perhaps add `static import core.stdc.stdio;`
fail_compilation/fail313.d(29): Error: package `imports.pkg313` is not accessible here, perhaps add `static import imports.pkg313;`
---
*/
module test313;
Expand Down
10 changes: 5 additions & 5 deletions test/runnable/testdstress.d
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// PERMUTE_ARGS:

module dstress.run.module_01;
module run.module_01;

import core.memory;
import core.exception;
Expand Down Expand Up @@ -170,9 +170,9 @@ int i;

void test7()
{
assert(dstress.run.module_01.i==0);
dstress.run.module_01.i++;
assert(dstress.run.module_01.i==1);
assert(run.module_01.i==0);
run.module_01.i++;
assert(run.module_01.i==1);
}

/* ================================ */
Expand Down Expand Up @@ -699,7 +699,7 @@ void test32()
assert(!(ti is null));
writefln("%s %d %d", ti.toString(), ti.tsize, (MyUnion32*).sizeof);
assert(ti.tsize==(MyUnion32*).sizeof);
assert(ti.toString()=="dstress.run.module_01.MyUnion32*");
assert(ti.toString()=="run.module_01.MyUnion32*");
}

/* ================================ */
Expand Down
4 changes: 2 additions & 2 deletions test/runnable/testmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
// @uri@ news:ct428n$2qoe$1@digitaldaemon.com
// @url@ nntp://news.digitalmars.com/D.gnu/983

module dstress.run.unicode_06_哪里;
module run.unicode_06_哪里;

int 哪里(int ö){
return ö+2;
}

int main(){
assert(dstress.run.unicode_06_哪里.哪里(2)==4);
assert(run.unicode_06_哪里.哪里(2)==4);
return 0;
}

0 comments on commit 01a6a5e

Please sign in to comment.