D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19189 - Accessing private member of template allowed
Summary: Accessing private member of template allowed
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 critical
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-25 15:00 UTC by Yuxuan Shui
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Yuxuan Shui 2018-08-25 15:00:22 UTC
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 basile-z 2018-08-25 15:09:46 UTC
**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