Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ 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;
}

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than deleting this, should we instead add static import pkgDIP32.datetime.common, perhaps in a different scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point in that: the code will error if that different scope does not include test7's scope.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative would be static assert(!__traits(compiles, ...)

}

// 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why, but for dstress.run.module_01 you would get that dstress.run is not accessible from the current module; that is probably because there is no directory structure that matches the module declaration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the folder run doesn't exist either, does it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually its runnable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That module declaration looks like a leftover from when code was copied into the test/runnable directory. Can't we just get rid of it?


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;
}