2
0
Эх сурвалжийг харах

[typer] fix bogus typing against enum constructor functions

closes #6609
Simon Krajewski 8 жил өмнө
parent
commit
0bf10a8563

+ 0 - 1
src/typing/matcher.ml

@@ -296,7 +296,6 @@ module Pattern = struct
 				let v = add_local s p in
 				let v = add_local s p in
 				PatVariable v
 				PatVariable v
 			| ECall(e1,el) ->
 			| ECall(e1,el) ->
-				let t = tfun (List.map (fun _ -> mk_mono()) el) t in
 				let e1 = type_expr ctx e1 (WithType t) in
 				let e1 = type_expr ctx e1 (WithType t) in
 				begin match e1.eexpr,follow e1.etype with
 				begin match e1.eexpr,follow e1.etype with
 					| TField(_, FEnum(en,ef)),TFun(_,TEnum(_,tl)) ->
 					| 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
 							loop (t :: stack) t2
 						| _ -> raise Exit
 						| _ -> raise Exit
 					end
 					end
-				(* We might type against an enum constructor. *)
-				| TFun(_,tr) ->
-					loop stack tr
 				| _ ->
 				| _ ->
 					raise Exit
 					raise Exit
 			in
 			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));
+	}
+}