[Issue 24387] New: Base class construction ignores private
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Feb 11 16:30:55 UTC 2024
    
    
  
https://issues.dlang.org/show_bug.cgi?id=24387
          Issue ID: 24387
           Summary: Base class construction ignores private
           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 without errors:
--- lib.d
module lib;
class Base
{
    private this(int n) {}
}
--- app.d
module app;
import lib;
class Derived : Base
{
    this() { super(42); }
}
---
According to the language spec [1], private symbols can only be accessed from
within the module that defines them. The section on base class construction [2]
does not mention any exception to that rule. Therefore, if the spec is correct,
the super(42) call should not compile.
[1] https://dlang.org/spec/attribute.html#private
[2] https://dlang.org/spec/class.html#base-construction
--
    
    
More information about the Digitalmars-d-bugs
mailing list