Skip to content

Commit 7d22f9c

Browse files
committed
fix incorrect dividing by zero with non constant
1 parent 3bdcaa4 commit 7d22f9c

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,22 +1265,16 @@ let bigint_comp (cmp : Lam_compat.comparison) ?comment (e0: t) (e1: t) =
12651265
bin ?comment (Lam_compile_util.jsop_of_comp cmp) e0 e1
12661266

12671267
let bigint_div ~checked ?comment (e0: t) (e1: t) =
1268-
match e1.expression_desc with
1269-
| Number (Bigint { i = i1 }) when i1 = "0" || i1 = "-0" ->
1270-
if checked then
1271-
runtime_call Js_runtime_modules.bigint "div" [e0; e1]
1272-
else
1273-
bigint_op ?comment Div e0 e1
1274-
| _ -> bigint_op ?comment Div e0 e1
1268+
if checked then
1269+
runtime_call Js_runtime_modules.bigint "div" [e0; e1]
1270+
else
1271+
bigint_op ?comment Div e0 e1
12751272

12761273
let bigint_mod ~checked ?comment (e0: t) (e1: t) =
1277-
match e1.expression_desc with
1278-
| Number (Bigint { i = i1 }) when i1 = "0" || i1 = "-0" ->
1279-
if checked then
1280-
runtime_call Js_runtime_modules.bigint "mod_" [e0; e1]
1281-
else
1282-
bigint_op ?comment Mod e0 e1
1283-
| _ -> bigint_op ?comment Mod e0 e1
1274+
if checked then
1275+
runtime_call Js_runtime_modules.bigint "mod_" [e0; e1]
1276+
else
1277+
bigint_op ?comment Mod e0 e1
12841278

12851279
(* TODO -- alpha conversion
12861280
remember to add parens..

0 commit comments

Comments
 (0)