Skip to content

Commit 12151e6

Browse files
Simn0b1kn00b
authored andcommitted
[typer] type operator lhs against expected type (HaxeFoundation#11428)
see HaxeFoundation#10981
1 parent 5a24a1e commit 12151e6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/typing/operators.ml

+4
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ let type_non_assign_op ctx op e1 e2 is_assign_op abstract_overload_only with_typ
630630
WithType.value
631631
in
632632
let e1 = type_expr ctx e1 wt in
633+
let e1 = match wt with
634+
| WithType.WithType(t,_) -> AbstractCast.cast_or_unify ctx t e1 e1.epos
635+
| _ -> e1
636+
in
633637
let result = if abstract_overload_only then begin
634638
let e2 = type_binop_rhs ctx op e1 e2 is_assign_op with_type p in
635639
try_abstract_binop_overloads ctx op e1 e2 is_assign_op p
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package unit.issues;
2+
3+
import haxe.EnumFlags;
4+
5+
private enum E {
6+
A;
7+
B;
8+
}
9+
10+
class Issue10981 extends Test {
11+
function test() {
12+
var flags:EnumFlags<E> = A | B;
13+
eq(3, flags.toInt());
14+
}
15+
}

0 commit comments

Comments
 (0)