Bug 23991 – [REG2.087.0] Private top-level overloads are callable if any overload is public

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-14T11:46:15Z
Last change time
2023-06-19T09:41:37Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Vladimir Panteleev
See also
https://issues.dlang.org/show_bug.cgi?id=23992

Comments

Comment #0 by dlang-bugzilla — 2023-06-14T11:46:15Z
///////// p.d ///////// private void fun() {} public void fun(int) {} //////// test.d /////// import p; void main() { fun(); } /////////////////////// Introduced in https://github.com/dlang/dmd/pull/9636
Comment #1 by default_357-line — 2023-06-14T12:07:07Z
Not a dupe, but see also https://issues.dlang.org/show_bug.cgi?id=23947 I believe this whole class of issues arises from the use of `mostVisibleOverload` in `checkAccess`: if only one of a set of overloads is public, it considers all of them public. It's supposed to re-check permissions once it has selected an overload, but it often does not do so.
Comment #2 by dlang-bugzilla — 2023-06-14T12:48:00Z
(In reply to FeepingCreature from comment #1) > Not a dupe, but see also https://issues.dlang.org/show_bug.cgi?id=23947 Not a dupe but https://issues.dlang.org/show_bug.cgi?id=23992 is! Plz bisect bugs (many many bugs filed here are actually regressions) and post the link to the bug in the introducing PR, this is a very good way to detect duplicates (much more precise than keyword search). https://github.com/CyberShadow/misc/blob/master/dreg.d should help with this.
Comment #3 by razvan.nitu1305 — 2023-06-19T09:31:17Z
This is a dupe of a long standing issue: https://issues.dlang.org/show_bug.cgi?id=3254 . I have repeatedly tried to fix it, but unfortunately, as long as we support public aliases to public symbols with the current alias eager resolution scheme it is impossible to fix this. *** This issue has been marked as a duplicate of issue 3254 ***
Comment #4 by dlang-bugzilla — 2023-06-19T09:35:49Z
OK, but I am curious why the test program above correctly failed to compile before 2.087.0. In other words, how can this be a long-standing issue and a regression at the same time?
Comment #5 by razvan.nitu1305 — 2023-06-19T09:41:37Z
This is just a hypothesis, I haven't checked it but: support for public aliases to private functions is a half baked feature. I wouldn't be surprised if its implementation accidentally made this case to work but disabled a proper use case for the alias to private symbols. Then, maybe the alias problem was solved and the overload problem returned.