Skip to content

Commit 73dd051

Browse files
committed
Fix Issue 17625 - Confusing error message for private functions in different modules
1 parent 18d43f2 commit 73dd051

11 files changed

Lines changed: 43 additions & 19 deletions

File tree

src/dmd/dsymbol.d

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,9 +1349,15 @@ public:
13491349
/* If both s2 and s are overloadable (though we only
13501350
* need to check s once)
13511351
*/
1352+
13521353
if ((s2.isOverloadSet() || s2.isOverloadable()) && (a || s.isOverloadable()))
13531354
{
1354-
a = mergeOverloadSet(ident, a, s2);
1355+
if (symbolIsVisible(this, s2))
1356+
{
1357+
a = mergeOverloadSet(ident, a, s2);
1358+
}
1359+
if (!symbolIsVisible(this, s))
1360+
s = s2;
13551361
continue;
13561362
}
13571363
if (flags & IgnoreAmbiguous) // if return NULL on ambiguity

src/dmd/func.d

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,7 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco
23412341
Dsymbol next;
23422342
for (Dsymbol d = fstart; d; d = next)
23432343
{
2344+
import dmd.access : checkSymbolAccess;
23442345
if (auto od = d.isOverDeclaration())
23452346
{
23462347
if (od.hasOverloads)
@@ -2353,7 +2354,6 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco
23532354
*/
23542355
if (sc)
23552356
{
2356-
import dmd.access : checkSymbolAccess;
23572357
if (checkSymbolAccess(sc, od))
23582358
{
23592359
if (int r = overloadApply(od.aliassym, dg, sc))
@@ -2393,7 +2393,6 @@ extern (D) int overloadApply(Dsymbol fstart, scope int delegate(Dsymbol) dg, Sco
23932393
{
23942394
if (sc)
23952395
{
2396-
import dmd.access : checkSymbolAccess;
23972396
if (checkSymbolAccess(sc, ad))
23982397
next = ad.toAlias();
23992398
}

test/compilable/checkimports3.d

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
REQUIRED_ARGS: -transition=checkimports -de
3+
*/
4+
import imports.checkimports3a;
5+
import imports.checkimports3b;
6+
import imports.checkimports3c;
7+
8+
void test()
9+
{
10+
foo();
11+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/fail_compilation/checkimports3.d

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/fail_compilation/dip22e.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TEST_OUTPUT:
44
---
55
fail_compilation/dip22e.d(16): Deprecation: imports.dip22d.foo is not visible from module dip22e
66
fail_compilation/dip22e.d(16): Error: function `imports.dip22d.foo` is not accessible from module `dip22e`
7-
fail_compilation/dip22e.d(17): Deprecation: local import search method found overloadset dip22e.bar (2 overloads) instead of function imports.dip22e.bar
7+
fail_compilation/dip22e.d(17): Deprecation: local import search method found overloadset dip22e.bar (1 overloads) instead of function imports.dip22e.bar
88
---
99
*/
1010

test/fail_compilation/fail17625.d

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
TEST_OUTPUT:
3+
---
4+
fail_compilation/fail17625.d(16): Deprecation: b17625.boo is not visible from module fail17625
5+
fail_compilation/fail17625.d(16): Error: function `b17625.boo` is not accessible from module `fail17625`
6+
---
7+
*/
8+
9+
module fail17625;
10+
11+
import imports.a17625;
12+
import imports.b17625;
13+
14+
void main()
15+
{
16+
boo();
17+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module a17625;
2+
3+
private int boo() { return 69; }

0 commit comments

Comments
 (0)