Nicolas Cannasse há 8 anos atrás
pai
commit
67b084c3a5

+ 16 - 1
src/typing/typeload.ml

@@ -3314,9 +3314,24 @@ let init_module_type ctx context_init do_init (decl,p) =
 			if (Meta.has Meta.Eager d.d_meta) then
 			if (Meta.has Meta.Eager d.d_meta) then
 				follow tt
 				follow tt
 			else begin
 			else begin
+				let rec check_rec tt =
+					if tt == t.t_type then error "Recursive typedef is not allowed" p;
+					match tt with
+					| TMono r ->
+						(match !r with
+						| None -> ()
+						| Some t -> check_rec t)
+					| TLazy r ->
+						check_rec ((!r)());
+					| TType (td,tl) ->
+						if td == t then error "Recursive typedef is not allowed" p;
+						check_rec (apply_params td.t_params tl td.t_type)
+					| _ ->
+						()
+				in
 				let f r =
 				let f r =
-					if t.t_type == follow tt then error "Recursive typedef is not allowed" p;
 					r := (fun() -> tt);
 					r := (fun() -> tt);
+					check_rec tt;
 					tt
 					tt
 				in
 				in
 				let r = exc_protect ctx f "typedef_rec_check" in
 				let r = exc_protect ctx f "typedef_rec_check" in

+ 1 - 0
tests/unit/compiler_loops/Issue5345.hx

@@ -0,0 +1 @@
+typedef Issue5345 = Issue5345;

+ 2 - 0
tests/unit/compiler_loops/Issue5345b.hx

@@ -0,0 +1,2 @@
+typedef Issue5345 = Issue5345b;
+typedef Issue5345b = Issue5345;

+ 2 - 0
tests/unit/compiler_loops/Issue5345c.hx

@@ -0,0 +1,2 @@
+typedef Issue5345<T> = Issue5345b<T>;
+typedef Issue5345b<T> = Issue5345<T>;