فهرست منبع

fix related to inline untyped expressions (fix context cache leak)

Nicolas Cannasse 12 سال پیش
والد
کامیت
cb7de35b62
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      optimizer.ml

+ 7 - 1
optimizer.ml

@@ -142,7 +142,10 @@ let rec type_inline ctx cf f ethis params tret config p force =
 	let read_local v =
 		try
 			Hashtbl.find locals v.v_id
-		with Not_found ->
+		with Not_found -> try
+			(* if it's in our current local context, it's because we're inlining a local function *)
+			let v2 = PMap.find v.v_name ctx.locals in
+			if v != v2 then raise Not_found;
 			{
 				i_var = v;
 				i_subst = v;
@@ -151,6 +154,9 @@ let rec type_inline ctx cf f ethis params tret config p force =
 				i_force_temp = false;
 				i_read = 0;
 			}
+		with Not_found ->
+			(* it's an unbound local, let's clone it *)
+			local v
 	in
 	(* use default values for null/unset arguments *)
 	let rec loop pl al first =