www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19326] New: .tupleof sidesteps protection attributes


          Issue ID: 19326
           Summary: .tupleof sidesteps protection attributes
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

module foo;
struct S {
    private int i;
module bar;
import foo;
 safe unittest {
    S s;
    // Fails: struct `foo.S` member i is not accessible
    // Fails: struct `foo.S` member i is not accessible
    __traits(getMember, s, "i")++;
    // Compiles just fine:

This breaks guarantees about what's accessible from other modules, and can be
used to break invariants relied on in  trusted code.

At the very least, this should not be  safe.

Related: issue 15371

Oct 22 2018