Browse Source

removed premature abstract cast while typing against enum (fixes #10173)

Aleksandr Kuzmenko 4 years ago
parent
commit
6d42c8e454
2 changed files with 24 additions and 5 deletions
  1. 1 5
      src/typing/typer.ml
  2. 23 0
      tests/unit/src/unit/issues/Issue10173.hx

+ 1 - 5
src/typing/typer.ml

@@ -108,11 +108,7 @@ let maybe_type_against_enum ctx f with_type iscall p =
 							(try Type.unify t' t with Unify_error _ -> ());
 							AKExpr e
 						| _ ->
-							if iscall then
-								AKExpr e
-							else begin
-								AKExpr (AbstractCast.cast_or_unify ctx t e e.epos)
-							end
+							AKExpr e
 					end
 				| _ -> e (* ??? *)
 			end

+ 23 - 0
tests/unit/src/unit/issues/Issue10173.hx

@@ -0,0 +1,23 @@
+package unit.issues;
+
+class Issue10173 extends Test {
+	function test() {
+		var foo:Foo = Bar;
+		var i = 9999;
+		t(foo == i);
+		foo = Baz;
+		f(foo == i);
+	}
+}
+
+private enum abstract Foo(Int) to Int {
+	var Bar;
+	var Baz;
+
+	@:op(A == B) public static function eqInt(lhs:Foo, rhs:Int):Bool {
+		return switch lhs {
+			case Bar: true;
+			case Baz: false;
+		}
+	}
+}