www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23947] New: If a class overloads a method mixing private and

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

          Issue ID: 23947
           Summary: If a class overloads a method mixing private and
                    public and the last overload is public, the method is
                    always public.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider this code:

--- b.d
struct X { }
struct Y { }
class Class {
    private void handle(X x) { }
    public void handle(Y y) { }
}

--- a.d
import b;
void main() { Class.init.handle(X.init); }

It compiles, even though handle(X) is private. It correctly errors if the order
of handle() is swapped, and permits calling with Y.init - it only assumes all
methods are public if the last method is public.

Wow.

--
May 30 2023