浏览代码

a few more finally (see #7667)

ncannasse 6 年之前
父节点
当前提交
70e29371bf
共有 2 个文件被更改,包括 2 次插入6 次删除
  1. 1 3
      src/codegen/codegen.ml
  2. 1 3
      src/core/abstract.ml

+ 1 - 3
src/codegen/codegen.ml

@@ -554,9 +554,7 @@ module UnificationCallback = struct
 		match e.eexpr with
 			| TFunction tf ->
 				tf_stack := tf :: !tf_stack;
-				let etf = {e with eexpr = TFunction({tf with tf_expr = run f tf.tf_expr})} in
-				tf_stack := List.tl !tf_stack;
-				etf
+				Std.finally (fun() -> tf_stack := List.tl !tf_stack) (fun() -> {e with eexpr = TFunction({tf with tf_expr = run f tf.tf_expr})}) ()
 			| _ ->
 				check (Type.map_expr (run ff) e)
 end;;

+ 1 - 3
src/core/abstract.ml

@@ -74,9 +74,7 @@ let rec get_underlying_type a pl =
 			| _ ->
 				t
 		in
-		let t = loop t in
-		underlying_type_stack := List.tl !underlying_type_stack;
-		t
+		Std.finally (fun() -> underlying_type_stack := List.tl !underlying_type_stack) loop t
 	in
 	try
 		if not (Meta.has Meta.MultiType a.a_meta) then raise Not_found;