diff --git a/src/typing/operators.ml b/src/typing/operators.ml index bc5bf5b1cd9..c297650c1a3 100644 --- a/src/typing/operators.ml +++ b/src/typing/operators.ml @@ -630,6 +630,10 @@ let type_non_assign_op ctx op e1 e2 is_assign_op abstract_overload_only with_typ WithType.value in let e1 = type_expr ctx e1 wt in + let e1 = match wt with + | WithType.WithType(t,_) -> AbstractCast.cast_or_unify ctx t e1 e1.epos + | _ -> e1 + in let result = if abstract_overload_only then begin let e2 = type_binop_rhs ctx op e1 e2 is_assign_op with_type p in try_abstract_binop_overloads ctx op e1 e2 is_assign_op p diff --git a/tests/unit/src/unit/issues/Issue10981.hx b/tests/unit/src/unit/issues/Issue10981.hx new file mode 100644 index 00000000000..8782e452d55 --- /dev/null +++ b/tests/unit/src/unit/issues/Issue10981.hx @@ -0,0 +1,15 @@ +package unit.issues; + +import haxe.EnumFlags; + +private enum E { + A; + B; +} + +class Issue10981 extends Test { + function test() { + var flags:EnumFlags = A | B; + eq(3, flags.toInt()); + } +}