You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module foo;
struct S {
private int i;
}
----
module bar;
import foo;
@safe unittest {
S s;
// Fails: struct `foo.S` member i is not accessible
s.i++;
// Fails: struct `foo.S` member i is not accessible
__traits(getMember, s, "i")++;
// Compiles just fine:
s.tupleof[0]++;
}
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
The text was updated successfully, but these errors were encountered:
peter.alexander.au (@Poita) commented on 2018-10-22T23:55:50Z
It probably goes without saying, but many parts of Phobos use tupleof, so a generously sprinkling of @trusted would be needed. Likely this will break much 3rd party code although that is pure speculation on my part.
Simen Kjaeraas reported this on 2018-10-22T14:08:26Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=19326
CC List
Description
module foo; struct S { private int i; } ---- module bar; import foo; @safe unittest { S s; // Fails: struct `foo.S` member i is not accessible s.i++; // Fails: struct `foo.S` member i is not accessible __traits(getMember, s, "i")++; // Compiles just fine: s.tupleof[0]++; } 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 15371The text was updated successfully, but these errors were encountered: