2012-05-11 13:09:19 -07:00
|
|
|
// Check that pure functions cannot modify aliased state.
|
|
|
|
|
|
|
|
pure fn modify_in_ref(&&sum: {mut f: int}) {
|
2012-05-23 11:55:32 -07:00
|
|
|
sum.f = 3; //! ERROR assigning to mutable field prohibited in pure context
|
2012-05-11 13:09:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pure fn modify_in_box(sum: @mut {f: int}) {
|
2012-05-23 11:55:32 -07:00
|
|
|
sum.f = 3; //! ERROR assigning to mutable field prohibited in pure context
|
2012-05-11 13:09:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl foo for int {
|
|
|
|
pure fn modify_in_box_rec(sum: @{mut f: int}) {
|
2012-05-23 11:55:32 -07:00
|
|
|
sum.f = self; //! ERROR assigning to mutable field prohibited in pure context
|
2012-05-11 13:09:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
}
|