From aca10e8a720d8a00a09184e5fc065665ca3a2c13 Mon Sep 17 00:00:00 2001 From: RazvanN7 Date: Tue, 3 Jul 2018 11:38:22 +0300 Subject: [PATCH] Turn deprecation into error for issue 313 --- ...qn_imports_bypass_private_imports_error.dd | 20 +++++++++++++++++++ src/dmd/access.d | 4 ++-- test/compilable/testDIP37.d | 1 - test/fail_compilation/fail313.d | 11 +++++----- test/runnable/testdstress.d | 10 +++++----- test/runnable/testmodule.d | 4 ++-- 6 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 changelog/fqn_imports_bypass_private_imports_error.dd diff --git a/changelog/fqn_imports_bypass_private_imports_error.dd b/changelog/fqn_imports_bypass_private_imports_error.dd new file mode 100644 index 000000000000..f1433af0f39b --- /dev/null +++ b/changelog/fqn_imports_bypass_private_imports_error.dd @@ -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`. diff --git a/src/dmd/access.d b/src/dmd/access.d index 711fab020748..57ff3716ea18 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -457,9 +457,9 @@ extern (C++) 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; } diff --git a/test/compilable/testDIP37.d b/test/compilable/testDIP37.d index d3482f9057c5..591f6bd90a47 100644 --- a/test/compilable/testDIP37.d +++ b/test/compilable/testDIP37.d @@ -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 diff --git a/test/fail_compilation/fail313.d b/test/fail_compilation/fail313.d index 116b3834f7dd..81e6addd9704 100644 --- a/test/fail_compilation/fail313.d +++ b/test/fail_compilation/fail313.d @@ -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; diff --git a/test/runnable/testdstress.d b/test/runnable/testdstress.d index a7f644485b23..aae52da8cc7e 100644 --- a/test/runnable/testdstress.d +++ b/test/runnable/testdstress.d @@ -1,6 +1,6 @@ // PERMUTE_ARGS: -module dstress.run.module_01; +module run.module_01; import core.memory; import core.exception; @@ -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); } /* ================================ */ @@ -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*"); } /* ================================ */ diff --git a/test/runnable/testmodule.d b/test/runnable/testmodule.d index 5d81588de9d7..45da7d1659db 100644 --- a/test/runnable/testmodule.d +++ b/test/runnable/testmodule.d @@ -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; }