Browse Source

fix infinite recursion in update_cache_dependencies (closes #9397)

Aleksandr Kuzmenko 5 years ago
parent
commit
8c254fb837

+ 5 - 1
src/codegen/codegen.ml

@@ -75,6 +75,7 @@ let escape_res_name name allow_dirs =
 			"-x" ^ (string_of_int (Char.code chr))) name
 			"-x" ^ (string_of_int (Char.code chr))) name
 
 
 let update_cache_dependencies t =
 let update_cache_dependencies t =
+	let visited_anons = ref [] in
 	let rec check_t m t = match t with
 	let rec check_t m t = match t with
 		| TInst(c,tl) ->
 		| TInst(c,tl) ->
 			add_dependency m c.cl_module;
 			add_dependency m c.cl_module;
@@ -92,7 +93,10 @@ let update_cache_dependencies t =
 			List.iter (fun (_,_,t) -> check_t m t) targs;
 			List.iter (fun (_,_,t) -> check_t m t) targs;
 			check_t m tret;
 			check_t m tret;
 		| TAnon an ->
 		| TAnon an ->
-			PMap.iter (fun _ cf -> check_field m cf) an.a_fields
+			if not (List.memq an !visited_anons) then begin
+				visited_anons := an :: !visited_anons;
+				PMap.iter (fun _ cf -> check_field m cf) an.a_fields
+			end
 		| TMono r ->
 		| TMono r ->
 			(match r.tm_type with
 			(match r.tm_type with
 			| Some t -> check_t m t
 			| Some t -> check_t m t

+ 12 - 0
tests/misc/compiler_loops/projects/Issue9397/Main.hx

@@ -0,0 +1,12 @@
+class Element {
+	var parentNode: INode & {};
+}
+typedef INode = {
+	final inodeField: INode & {};
+}
+
+class Main {
+	static function main() {
+
+	}
+}

+ 1 - 0
tests/misc/compiler_loops/projects/Issue9397/compile.hxml

@@ -0,0 +1 @@
+-main Main