Bug 24387 – Base class construction ignores private

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-02-11T16:30:55Z
Last change time
2024-02-13T12:21:54Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2024-02-11T16:30:55Z
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
Comment #1 by dlang-bot — 2024-02-12T11:59:25Z
@ntrel created dlang/dmd pull request #16180 "Fix Bugzilla 24387 - Base class construction ignores private" fixing this issue: - Fix Bugzilla 24387 - Base class construction ignores private https://github.com/dlang/dmd/pull/16180
Comment #2 by dlang-bot — 2024-02-13T12:21:54Z
dlang/dmd pull request #16180 "Fix Bugzilla 24387 - Base class construction ignores private" was merged into master: - 0dbefb21cb0edd86b668bac38c8680f7bedb3791 by Nick Treleaven: Fix Bugzilla 24387 - Base class construction ignores private https://github.com/dlang/dmd/pull/16180