Closed
Description
Here is some code that segfaults.
If I replace the impl with fn with(x: &X, blk: fn(...))
then the program is correctly rejected.
import either::*;
enum X = Either<(uint,uint),fn()>;
impl &X {
fn with(blk: fn(x: &Either<(uint,uint),fn()>)) {
blk(&**self)
}
}
fn main() {
let mut x = X(Right(main));
do (&mut x).with |opt| { // this should be illegal
match *opt {
Right(f) => {
x = X(Left((0,0)));
f()
},
_ => fail
}
}
}