Closed
Description
The following code typechecks and runs; it causes a memory leak (and thus the runtime to trip an assert).
enum cycle {
node({mut a: ~cycle}),
empty
}
fn main() {
let x = ~node({mut a: ~empty});
// Create a cycle!
alt check *x { node(y) { y.a <- x } };
}
It works by moving a unique pointer into the object it points to. (This code also works if the <- is a regular assignment, thanks to the last-use analysis.) Trying to log the value produces a segfault.