Modify alt-pattern-drop.rs to also insure the slot bound in the pattern doesn't also get dropped (again) at the end of the block containing the alt.

This commit is contained in:
Roy Frostig 2010-08-27 13:48:45 -07:00
parent 6f52ba7cc5
commit 0d15ae4f7a

View File

@ -5,15 +5,21 @@ import std._str;
type t = tag(make_t(str), clam());
fn main() {
let str s = "hi"; // ref up
fn foo(str s) {
let t x = make_t(s); // ref up
alt (x) {
case (make_t(y)) { log y; } // ref up and ref down
case (make_t(y)) { log y; } // ref up then down
case (_) { log "?"; fail; }
}
log _str.refcount(s);
check (_str.refcount(s) == 2u);
check (_str.refcount(s) == 3u);
}
fn main() {
let str s = "hi"; // ref up
foo(s); // ref up then down
log _str.refcount(s);
check (_str.refcount(s) == 1u);
}