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

fix better and add test

closes #12182
Simon Krajewski 3 сар өмнө
parent
commit
a9cbca65fe

+ 1 - 1
src/typing/operators.ml

@@ -451,7 +451,7 @@ let find_abstract_binop_overload ctx op e1 e2 a c tl left is_assign_op p =
 	let is_eq_op = match op with OpEq | OpNotEq -> true | _ -> false in
 	let is_eq_op = match op with OpEq | OpNotEq -> true | _ -> false in
 	if is_eq_op then begin match follow e1.etype,follow e2.etype with
 	if is_eq_op then begin match follow e1.etype,follow e2.etype with
 		| TMono _,_ | _,TMono _ ->
 		| TMono _,_ | _,TMono _ ->
-			unify ctx e1.etype e2.etype p
+			(try Type.unify e1.etype e2.etype with Unify_error _ -> () (* this will fail later again *));
 		| _ ->
 		| _ ->
 			()
 			()
 	end;
 	end;

+ 12 - 0
tests/misc/projects/Issue12182/Main.hx

@@ -0,0 +1,12 @@
+abstract A(String) {
+	public function new(s:String) {
+		this = s;
+	}
+}
+
+function main() {
+	var a = new A("foo");
+	var b = null;
+	b.field = 1;
+	a == b;
+}

+ 2 - 0
tests/misc/projects/Issue12182/compile-fail.hxml

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

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

@@ -0,0 +1 @@
+Main.hx:11: characters 2-8 : A should be { field : Int }