Skip to content

Commit f74b771

Browse files
committed
Fix instanceof array.
1 parent db906a2 commit f74b771

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jscomp/core/lam_compile.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -744,21 +744,21 @@ and compile_untagged_cases cxt switch_exp table default =
744744
let literal = function
745745
| literal -> E.literal literal
746746
in
747-
let add_runtime_type_check (literal: Lambda.literal) x = match literal with
747+
let add_runtime_type_check (literal: Lambda.literal) x y = match literal with
748748
| Block IntType
749749
| Block StringType
750750
| Block FloatType
751-
| Block Object -> E.typeof x
752-
| Block Array -> assert false
751+
| Block Object -> E.string_equal (E.typeof y) x
752+
| Block Array -> E.instanceof x y
753753
| Block Unknown ->
754754
(* This should not happen because unknown must be the only non-literal case *)
755755
assert false
756756
| Bool _ | Float _ | Int _ | String _ | Null | Undefined -> x in
757757
let mk_eq (i : Lambda.literal option) x j y = match i, j with
758-
| Some literal, _ ->
759-
E.string_equal x (add_runtime_type_check literal y)
758+
| Some literal, _ -> (* XX *)
759+
add_runtime_type_check literal x y
760760
| _, Some literal ->
761-
E.string_equal (add_runtime_type_check literal x) y
761+
add_runtime_type_check literal y x
762762
| _ -> E.string_equal x y
763763
in
764764
let is_array (l, _) = l = Lambda.Block Array in

0 commit comments

Comments
 (0)