Selaa lähdekoodia

properly report abstract chains (closes #3782)

Simon Krajewski 10 vuotta sitten
vanhempi
commit
b2c316b93d

+ 9 - 0
tests/misc/projects/Issue3782/Main.hx

@@ -0,0 +1,9 @@
+abstract Ab1(Ab2) from Ab2 {}
+abstract Ab2(Ab1) from Ab1 {}
+
+class Main {
+    static function main() {
+		var a:Ab1 = null;
+		var b:Ab2 = a;
+    }
+}

+ 2 - 0
tests/misc/projects/Issue3782/compile-fail.hxml

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

+ 1 - 0
tests/misc/projects/Issue3782/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:1: characters 0-29 : Abstract chain detected: Ab1 -> Ab2 -> Ab1

+ 2 - 4
type.ml

@@ -1869,10 +1869,8 @@ module Abstract = struct
 			let t = match follow t with
 				| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
 					if List.mem a !underlying_type_stack then begin
-						(* let s = String.concat " -> " (List.map (fun a -> s_type_path a.a_path) (List.rev (a :: !underlying_type_stack))) in *)
-						(* technically this should be done at type declaration level *)
-						(* error ("Abstract chain detected: " ^ s) a.a_pos *)
-						assert false
+						let s = String.concat " -> " (List.map (fun a -> s_type_path a.a_path) (List.rev (a :: !underlying_type_stack))) in
+						raise (Error("Abstract chain detected: " ^ s,a.a_pos))
 					end;
 					get_underlying_type a tl
 				| _ ->