- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
A-type-systemArea: Type systemArea: Type system
Milestone
Description
When a struct is accessed via a pointer then its private fields are accessible:
mod my_mod {
    pub struct MyStruct {
        priv priv_field: int
    }
    pub fn MyStruct () -> MyStruct {
        MyStruct {priv_field: 4}
    }
}
fn main() {
    let my_struct = my_mod::MyStruct();
    let _woohoo = (&my_struct).priv_field; // compiles but shouldn't
    let _woohoo = (~my_struct).priv_field; // ditto
    let _woohoo = (@my_struct).priv_field; // ditto
    let nope = my_struct.priv_field;       // compile error as expected
}
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type system