Browse Source

ensure that load_core_type always correctly creates the dependency (fixed EReg and Iterator dependency leak)

Nicolas Cannasse 11 years ago
parent
commit
5291623b74
1 changed files with 8 additions and 1 deletions
  1. 8 1
      typeload.ml

+ 8 - 1
typeload.ml

@@ -590,6 +590,12 @@ let load_core_type ctx name =
 	let show = hide_types ctx in
 	let t = load_instance ctx { tpackage = []; tname = name; tparams = []; tsub = None; } null_pos false in
 	show();
+	add_dependency ctx.m.curmod (match t with
+	| TInst (c,_) -> c.cl_module
+	| TType (t,_) -> t.t_module
+	| TAbstract (a,_) -> a.a_module
+	| TEnum (e,_) -> e.e_module
+	| _ -> assert false);
 	t
 
 let t_iterator ctx =
@@ -597,6 +603,7 @@ let t_iterator ctx =
 	match load_type_def ctx null_pos { tpackage = []; tname = "Iterator"; tparams = []; tsub = None } with
 	| TTypeDecl t ->
 		show();
+		add_dependency ctx.m.curmod t.t_module;
 		if List.length t.t_types <> 1 then assert false;
 		let pt = mk_mono() in
 		apply_params t.t_types [pt] t.t_type, pt
@@ -2338,7 +2345,7 @@ let type_module ctx m file tdecls p =
 	if ctx.g.std != null_module then begin
 		add_dependency m ctx.g.std;
 		(* this will ensure both String and (indirectly) Array which are basic types which might be referenced *)
-		add_dependency m (match follow (load_core_type ctx "String") with TInst (c,_) -> c.cl_module | _ -> assert false);
+		ignore(load_core_type ctx "String");
 	end;
 	(* define the per-module context for the next pass *)
 	let ctx = {