Explorar el Código

[typer] don't immediately fail on incompatible macro @:from casts

closes #8779
Simon Krajewski hace 6 años
padre
commit
12df3cee13
Se han modificado 2 ficheros con 26 adiciones y 1 borrados
  1. 1 1
      src/context/abstractCast.ml
  2. 25 0
      tests/unit/src/unit/issues/Issue8779.hx

+ 1 - 1
src/context/abstractCast.ml

@@ -17,8 +17,8 @@ let rec make_static_call ctx c cf a pl args t p =
 					| Some e -> type_expr ctx e (WithType.with_type t)
 					| None ->  type_expr ctx (EConst (Ident "null"),p) WithType.value
 				in
-				let e = cast_or_unify ctx t e p in
 				ctx.with_type_stack <- List.tl ctx.with_type_stack;
+				let e = try cast_or_unify_raise ctx t e p with Error(Unify _,_) -> raise Not_found in
 				f();
 				e
 			| _ -> assert false

+ 25 - 0
tests/unit/src/unit/issues/Issue8779.hx

@@ -0,0 +1,25 @@
+package unit.issues;
+
+import utest.Assert;
+
+@:forward
+private abstract Suite(SuiteObject) from SuiteObject to SuiteObject {
+	@:from
+	public static macro function ofAny(expr:haxe.macro.Expr) {
+		return expr;
+	}
+}
+
+
+private interface SuiteObject {}
+
+private class BasicSuite implements SuiteObject {
+	public function new() {}
+}
+
+class Issue8779 extends unit.Test {
+	function test() {
+		var suite:Suite = new BasicSuite();
+		Assert.pass();
+	}
+}