Skip to content

Commit

Permalink
[typer] type operator lhs against expected type (HaxeFoundation#11428)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn authored and 0b1kn00b committed Jan 25, 2024
1 parent 5a24a1e commit 12151e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/typing/operators.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/src/unit/issues/Issue10981.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package unit.issues;

import haxe.EnumFlags;

private enum E {
A;
B;
}

class Issue10981 extends Test {
function test() {
var flags:EnumFlags<E> = A | B;
eq(3, flags.toInt());
}
}

0 comments on commit 12151e6

Please sign in to comment.