瀏覽代碼

add missing `follow` when unifying constrained type parameter against `{}` (closes #3545)

Simon Krajewski 10 年之前
父節點
當前提交
2490b8dbc4
共有 2 個文件被更改,包括 15 次插入1 次删除
  1. 14 0
      tests/unit/src/unit/issues/Issue3545.hx
  2. 1 1
      type.ml

+ 14 - 0
tests/unit/src/unit/issues/Issue3545.hx

@@ -0,0 +1,14 @@
+package unit.issues;
+
+typedef Constraint = { }
+
+typedef T1<T:Constraint> = { }
+
+typedef T2<T:Constraint> = {
+	x:T1<T>
+}
+
+class Issue3545 extends Test {
+	// if it compiles it works
+	function test() { }
+}

+ 1 - 1
type.ml

@@ -1379,7 +1379,7 @@ let rec unify a b =
 		if PMap.is_empty an.a_fields then (match c.cl_kind with
 		if PMap.is_empty an.a_fields then (match c.cl_kind with
 			| KTypeParameter pl ->
 			| KTypeParameter pl ->
 				(* one of the constraints must unify with { } *)
 				(* one of the constraints must unify with { } *)
-				if not (List.exists (fun t -> match t with TInst _ | TAnon _ -> true | _ -> false) pl) then error [cannot_unify a b]
+				if not (List.exists (fun t -> match follow t with TInst _ | TAnon _ -> true | _ -> false) pl) then error [cannot_unify a b]
 			| _ -> ());
 			| _ -> ());
 		(try
 		(try
 			PMap.iter (fun n f2 ->
 			PMap.iter (fun n f2 ->