Pārlūkot izejas kodu

properly detect unification errors upon recursive macro @:from (closes #10264)

Aleksandr Kuzmenko 3 gadi atpakaļ
vecāks
revīzija
5a6c19d362

+ 4 - 1
src/context/abstractCast.ml

@@ -35,7 +35,10 @@ and do_check_cast ctx uctx tleft eright p =
 		if cf.cf_kind = Method MethMacro then begin
 			match cast_stack.rec_stack with
 			| previous_from :: _ when previous_from == cf ->
-				raise (Error (Unify [cannot_unify eright.etype tleft], eright.epos));
+				(try
+					Type.unify_custom uctx eright.etype tleft;
+				with Unify_error l ->
+					raise (Error (Unify l, eright.epos)))
 			| _ -> ()
 		end;
 		if cf == ctx.curfield || rec_stack_memq cf cast_stack then error "Recursive implicit cast" p;

+ 10 - 0
tests/misc/projects/Issue10264/Main.hx

@@ -0,0 +1,10 @@
+function main() {
+	var d:Dynamic = null;
+	var v:MacroFrom = d;
+}
+
+abstract MacroFrom(String) to String {
+	@:from
+	public static macro function fromExpr(e:haxe.macro.Expr)
+		return macro ($e:Main.MacroFrom);
+}

+ 1 - 0
tests/misc/projects/Issue10264/compile-fail.hxml

@@ -0,0 +1 @@
+--main Main

+ 1 - 0
tests/misc/projects/Issue10264/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:9: characters 16-35 : Recursive implicit cast