Bug 18243 – selective import + overload = private visibility

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-16T19:03:11Z
Last change time
2018-01-25T17:23:07Z
Assigned to
No Owner
Creator
Răzvan Ștefănescu

Comments

Comment #0 by rumbu — 2018-01-16T19:03:11Z
module a; private import std.math: isNaN; //custom overload public bool isNaN(int i) { return false; } ============================= module b; import a; void foo() { bool b = isNaN(float.nan); //compiles successfully calling std.math.isNaN even it should not be visible. }
Comment #1 by rumbu — 2018-01-16T19:04:25Z
Comment #2 by greensunny12 — 2018-01-17T02:23:57Z
*** This issue has been marked as a duplicate of issue 17630 ***
Comment #3 by greensunny12 — 2018-01-17T09:40:58Z
I'm re-opening this as its slightly different to 17630 and it's probably worthwhile to add both tests to the testsuite once this gets fixed.
Comment #4 by razvan.nitu1305 — 2018-01-22T13:27:15Z
The problem here is that overload sets do not have a protection attribute. Moreover the symbolIsVisible function in the compiler takes a symbol and then checks if the most visible overload of that particular overload set is visible. This, obviously is problematic, since in this case std.math.isNaN is found and when the check for visibility is made the public overload is considered.
Comment #5 by razvan.nitu1305 — 2018-01-23T16:33:29Z
Comment #6 by github-bugzilla — 2018-01-25T17:23:06Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/a71ede3ac0ab8320cbd191d0c8cac4de402ec585 Fix Issue 18243 - selective import + overload = private visibility https://github.com/dlang/dmd/commit/ccbaaa14fa65c5066c832e222a14d190389e2470 Merge pull request #7766 from RazvanN7/Issue_18243 Fix Issue 18243 - selective import + overload = private visibility