Bug 19189 – Accessing private member of template allowed

Status
RESOLVED
Resolution
INVALID
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-08-25T15:00:22Z
Last change time
2020-03-21T03:56:41Z
Assigned to
No Owner
Creator
Yuxuan Shui

Comments

Comment #0 by yshuiv7 — 2018-08-25T15:00:22Z
Example: template A(T) { private enum A = T.sizeof; } template B(T) { private enum C = T.sizeof; } void main() { enum x = A!int; enum y = B!int.C; } Expected: Compilation error (or warning) Actual: No error generated
Comment #1 by b2.temp — 2018-08-25T15:09:46Z
**Within** a module its private members are accessible from its other members, this works like this by design. See point 2 here https://dlang.org/spec/attribute.html#visibility_attributes