Browse Source

[js] add missing dependency when injecting call stacks

closes #7908
Simon Krajewski 6 năm trước cách đây
mục cha
commit
b2f18ad0b0
1 tập tin đã thay đổi với 21 bổ sung18 xóa
  1. 21 18
      src/filters/jsExceptions.ml

+ 21 - 18
src/filters/jsExceptions.ml

@@ -186,24 +186,27 @@ let inject_callstack com type_filters =
 	in
 	match cCallStack with
 	| Some cCallStack ->
-		let rec loop e =
-			match e.eexpr with
-			| TTry (etry,[(v,ecatch)]) ->
-				let etry = loop etry in
-				let ecatch = loop ecatch in
-
-				let eCallStack = make_static_this cCallStack ecatch.epos in
-				let elastException = field eCallStack "lastException" t_dynamic ecatch.epos in
-				let elocal = make_local v ecatch.epos in
-				let eStoreException = mk (TBinop (Ast.OpAssign, elastException, elocal)) ecatch.etype ecatch.epos in
-				let ecatch = Type.concat eStoreException ecatch in
-				{ e with eexpr = TTry (etry,[(v,ecatch)]) }
-			| TTry _ ->
-				(* this should be handled by the filter above *)
-				assert false
-			| _ ->
-				Type.map_expr loop e
+		let run mt e =
+			let rec loop e =
+				match e.eexpr with
+				| TTry (etry,[(v,ecatch)]) ->
+					let etry = loop etry in
+					let ecatch = loop ecatch in
+					add_dependency (t_infos mt).mt_module cCallStack.cl_module;
+					let eCallStack = make_static_this cCallStack ecatch.epos in
+					let elastException = field eCallStack "lastException" t_dynamic ecatch.epos in
+					let elocal = make_local v ecatch.epos in
+					let eStoreException = mk (TBinop (Ast.OpAssign, elastException, elocal)) ecatch.etype ecatch.epos in
+					let ecatch = Type.concat eStoreException ecatch in
+					{ e with eexpr = TTry (etry,[(v,ecatch)]) }
+				| TTry _ ->
+					(* this should be handled by the filter above *)
+					assert false
+				| _ ->
+					Type.map_expr loop e
+			in
+			loop e
 		in
-		type_filters @ [ fun ctx t -> FiltersCommon.run_expression_filters ctx [loop] t ]
+		type_filters @ [ fun ctx t -> FiltersCommon.run_expression_filters ctx [run t] t ]
 	| None ->
 		type_filters