[Issue 24388] New: Private overload of public function can be called from other modules

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 11 17:06:40 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24388

          Issue ID: 24388
           Summary: Private overload of public function can be called from
                    other modules
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

As of DMD 2.107.0, the following program compiles and runs without errors:

--- lib.d
module lib;

import std.stdio;

private void fun(int) { writeln("int"); }
public void fun(string) { writeln("string"); }
--- app.d
module app;

import lib;

void main()
{
    int n;
    fun(n);
}
---

The output is:

---
int
---

Even thought lib.fun(int) is private, it is able to be called from the app
module as long as lib.fun(string) is public.

Unlike in issue 23947, the order of the lib.fun overloads does not matter here.

--


More information about the Digitalmars-d-bugs mailing list