Procházet zdrojové kódy

[typer] dodge #7603

see #7603
Simon Krajewski před 6 roky
rodič
revize
00784982cb
2 změnil soubory, kde provedl 20 přidání a 1 odebrání
  1. 2 1
      src/typing/typer.ml
  2. 18 0
      tests/unit/src/unit/issues/Issue7603.hx

+ 2 - 1
src/typing/typer.ml

@@ -134,7 +134,8 @@ let maybe_type_against_enum ctx f with_type iscall p =
 				| AKExpr e ->
 				| AKExpr e ->
 					begin match follow e.etype with
 					begin match follow e.etype with
 						| TFun(_,t') when is_enum ->
 						| TFun(_,t') when is_enum ->
-							unify ctx t' t e.epos;
+							(* TODO: this is a dodge for #7603 *)
+							(try Type.unify t' t with Unify_error _ -> ());
 							AKExpr e
 							AKExpr e
 						| _ ->
 						| _ ->
 							if iscall then
 							if iscall then

+ 18 - 0
tests/unit/src/unit/issues/Issue7603.hx

@@ -0,0 +1,18 @@
+package unit.issues;
+
+private abstract Foo(String) {
+	@:from static public function from(bar: Bar):Foo {
+		return cast bar.getName();
+	}
+}
+
+private enum Bar {
+	A(v: Int);
+	B;
+}
+
+class Issue7603 extends unit.Test {
+	function test() {
+		var bar:Foo = A(200);
+	}
+}