소스 검색

fix gadt pattern matching bug, closes #6413

frabbit 8 년 전
부모
커밋
da0ac21a2b
2개의 변경된 파일31개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/typing/matcher.ml
  2. 30 0
      tests/unit/src/unit/issues/Issue6413.hx

+ 1 - 1
src/typing/matcher.ml

@@ -1142,7 +1142,7 @@ module TexprConverter = struct
 			let t_ef = match follow ef.ef_type with TFun(_,t) -> t | _ -> ef.ef_type in
 			let t_ef = apply_params ctx.type_params params (monomorphs en.e_params (monomorphs ef.ef_params t_ef)) in
 			let monos = List.map (fun t -> match follow t with
-				| TInst({cl_kind = KTypeParameter _},_) -> mk_mono()
+				| TInst({cl_kind = KTypeParameter _},_) | TMono _ -> mk_mono()
 				| _ -> t
 			) params in
 			let rec duplicate_monos t = match follow t with

+ 30 - 0
tests/unit/src/unit/issues/Issue6413.hx

@@ -0,0 +1,30 @@
+package unit.issues;
+
+private enum N {
+	N1;
+}
+
+private class PR {}
+private class VR {}
+
+private enum C<X> {
+	P:C<PR>;
+	V:C<VR>;
+}
+
+class Issue6413 extends Test {
+
+	function test () {
+		add(N1, P);
+	}
+
+	public function add <X>(n:N, c:C<X>) {
+		switch [n, c] {
+			case [N1, P]:
+				t(true);
+			case [N1, _]:
+				t(false);
+
+		}
+	}
+}