Sfoglia il codice sorgente

[typer] fix bogus typing against enum constructor functions

closes #6609
Simon Krajewski 8 anni fa
parent
commit
0bf10a8563
3 ha cambiato i file con 17 aggiunte e 4 eliminazioni
  1. 0 1
      src/typing/matcher.ml
  2. 0 3
      src/typing/typer.ml
  3. 17 0
      tests/unit/src/unit/issues/Issue6609.hx

+ 0 - 1
src/typing/matcher.ml

@@ -296,7 +296,6 @@ module Pattern = struct
 				let v = add_local s p in
 				PatVariable v
 			| ECall(e1,el) ->
-				let t = tfun (List.map (fun _ -> mk_mono()) el) t in
 				let e1 = type_expr ctx e1 (WithType t) in
 				begin match e1.eexpr,follow e1.etype with
 					| TField(_, FEnum(en,ef)),TFun(_,TEnum(_,tl)) ->

+ 0 - 3
src/typing/typer.ml

@@ -4104,9 +4104,6 @@ and maybe_type_against_enum ctx f with_type p =
 							loop (t :: stack) t2
 						| _ -> raise Exit
 					end
-				(* We might type against an enum constructor. *)
-				| TFun(_,tr) ->
-					loop stack tr
 				| _ ->
 					raise Exit
 			in

+ 17 - 0
tests/unit/src/unit/issues/Issue6609.hx

@@ -0,0 +1,17 @@
+package unit.issues;
+
+private enum MyEnum {
+	MyEnumConstructor(t:String -> MyEnum);
+}
+
+private abstract A(String -> MyEnum) to String -> MyEnum {
+	public function new(f) {
+		this = f;
+	}
+}
+
+class Issue6609 extends unit.Test {
+	function test() {
+		MyEnumConstructor(new A(null));
+	}
+}