Bläddra i källkod

detect more recursive abstracts

Simon Krajewski 9 år sedan
förälder
incheckning
ebe2ab6d50

+ 6 - 0
tests/misc/projects/Issue4761/Main1.hx

@@ -0,0 +1,6 @@
+typedef T = A;
+abstract A(T) { }
+
+class Main1 {
+	static function main() { }
+}

+ 2 - 0
tests/misc/projects/Issue4761/compile1-fail.hxml

@@ -0,0 +1,2 @@
+-main Main1
+--interp

+ 1 - 0
tests/misc/projects/Issue4761/compile1-fail.hxml.stderr

@@ -0,0 +1 @@
+Main1.hx:2: characters 0-17 : Abstract underlying type cannot be recursive

+ 6 - 1
typeload.ml

@@ -3172,7 +3172,12 @@ let init_module_type ctx context_init do_init (decl,p) =
 				if a.a_impl = None then error "Abstracts with underlying type must have an implementation" a.a_pos;
 				if Meta.has Meta.CoreType a.a_meta then error "@:coreType abstracts cannot have an underlying type" p;
 				let at = load_complex_type ctx p t in
-				(match at with TAbstract(a2,_) when a == a2 -> error "Abstract underlying type cannot be recursive" a.a_pos | _ -> ());
+				delay ctx PForce (fun () ->
+					begin match follow at with
+						| TAbstract(a2,_) when a == a2 -> error "Abstract underlying type cannot be recursive" a.a_pos
+						| _ -> ()
+					end;
+				);
 				a.a_this <- at;
 				is_type := true;
 			| APrivAbstract -> ()