Skip to content

Commit 1843c99

Browse files
committed
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).
1 parent 7c837b8 commit 1843c99

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/boot/me/typestate.ml

+12-4
Original file line numberDiff line numberDiff line change
@@ -1044,8 +1044,16 @@ let lifecycle_visitor
10441044
Ast.STMT_ret _
10451045
| Ast.STMT_be _ ->
10461046
() (* Taken care of in visit_stmt_post below. *)
1047-
| _ ->
1048-
let slots = stk_elts_from_bot blk_slots in
1047+
| _ ->
1048+
(* The blk_slots stack we have has accumulated slots in
1049+
* declaration order as we walked the block; the top of the
1050+
* stack is the last-declared slot. We want to generate
1051+
* slot-drop obligations here for the slots in top-down order
1052+
* (starting with the last-declared) but only hitting those
1053+
* slots that actually got initialized (went live) at some
1054+
* point in the block.
1055+
*)
1056+
let slots = stk_elts_from_top blk_slots in
10491057
let live =
10501058
List.filter
10511059
(fun i -> Hashtbl.mem live_block_slots i)
@@ -1122,7 +1130,7 @@ let lifecycle_visitor
11221130
(fst f.Ast.for_each_slot).id
11231131

11241132

1125-
| _ -> ()
1133+
| _ -> ()
11261134
end;
11271135
inner.Walk.visit_stmt_pre s
11281136
in
@@ -1133,7 +1141,7 @@ let lifecycle_visitor
11331141
Ast.STMT_ret _
11341142
| Ast.STMT_be _ ->
11351143
let stks = stk_elts_from_top block_slots in
1136-
let slots = List.concat (List.map stk_elts_from_bot stks) in
1144+
let slots = List.concat (List.map stk_elts_from_top stks) in
11371145
let live =
11381146
List.filter
11391147
(fun i -> Hashtbl.mem live_block_slots i)

0 commit comments

Comments
 (0)