Closed
Description
The following code compiles and outputs &10
.
fn each<T>(x: &[T], op: fn(elem: &T) -> bool) {
uint::range(0, x.len(), |i| op(&x[i]));
}
fn main() {
let x = ~[{mut a: 0}];
for each(x) |y| {
let z = &y.a;
x[0].a = 10;
log(error, z);
}
}
It also fails if you use vec::each
, which uses reference modes instead of region pointers. It should be rejected.