Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type operator lhs against expected type #11428

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}
Loading