aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-07-12 13:25:59 -0700
committerGraydon Hoare <[email protected]>2010-07-12 13:26:28 -0700
commit1843c99b6657c24ec510bac4e266cf7047a54ccf (patch)
tree5e12e9d225cf37f72bd3d516c46242082279437e /src
parentCorrect doubly-linked list management logic; bug exposed during conversation ... (diff)
downloadrust-1843c99b6657c24ec510bac4e266cf7047a54ccf.tar.xz
rust-1843c99b6657c24ec510bac4e266cf7047a54ccf.zip
Revert previous wrong-change on issue #106; was papering over wrongness in the runtime. Sad times. Closes #106 more correctly (and adds comment to explain).
Diffstat (limited to 'src')
-rw-r--r--src/boot/me/typestate.ml16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/boot/me/typestate.ml b/src/boot/me/typestate.ml
index 4c3dbe52..6e0b57e1 100644
--- a/src/boot/me/typestate.ml
+++ b/src/boot/me/typestate.ml
@@ -1044,8 +1044,16 @@ let lifecycle_visitor
Ast.STMT_ret _
| Ast.STMT_be _ ->
() (* Taken care of in visit_stmt_post below. *)
- | _ ->
- let slots = stk_elts_from_bot blk_slots in
+ | _ ->
+ (* The blk_slots stack we have has accumulated slots in
+ * declaration order as we walked the block; the top of the
+ * stack is the last-declared slot. We want to generate
+ * slot-drop obligations here for the slots in top-down order
+ * (starting with the last-declared) but only hitting those
+ * slots that actually got initialized (went live) at some
+ * point in the block.
+ *)
+ let slots = stk_elts_from_top blk_slots in
let live =
List.filter
(fun i -> Hashtbl.mem live_block_slots i)
@@ -1122,7 +1130,7 @@ let lifecycle_visitor
(fst f.Ast.for_each_slot).id
- | _ -> ()
+ | _ -> ()
end;
inner.Walk.visit_stmt_pre s
in
@@ -1133,7 +1141,7 @@ let lifecycle_visitor
Ast.STMT_ret _
| Ast.STMT_be _ ->
let stks = stk_elts_from_top block_slots in
- let slots = List.concat (List.map stk_elts_from_bot stks) in
+ let slots = List.concat (List.map stk_elts_from_top stks) in
let live =
List.filter
(fun i -> Hashtbl.mem live_block_slots i)