Skip to content

Commit f608b97

Browse files
committed
WIP
1 parent bc5cfe6 commit f608b97

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

compiler/lib/generate.ml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,10 +1056,13 @@ let remove_unused_tail_args ctx exact trampolined args =
10561056
else args
10571057
else args
10581058

1059-
let is_int = function
1060-
| J.ENum n -> J.Num.is_int n && not (J.Num.is_zero n)
1061-
| J.EBin ((J.Bor | J.Lsr), _, _) -> true
1062-
| _ -> false
1059+
let maybe_zero_or_nan = function
1060+
| J.ENum n -> (
1061+
match J.Num.to_string n with
1062+
| "NaN" -> true
1063+
| "-0." | "0." | "0" | "0." -> true
1064+
| J.EBin ((J.Bor | J.Lsr), _, _) -> false
1065+
| _ -> true)
10631066

10641067
let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
10651068
match e with
@@ -1359,7 +1362,7 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
13591362
let (px, cx), queue = access_queue' ~ctx queue x in
13601363
let (py, cy), queue = access_queue' ~ctx queue y in
13611364
let e =
1362-
if is_int cx || is_int cy
1365+
if not (maybe_zero_or_nan cx && maybe_zero_or_nan cy)
13631366
then bool (J.EBin (J.EqEqEq, cx, cy))
13641367
else
13651368
bool
@@ -1373,7 +1376,7 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
13731376
let (px, cx), queue = access_queue' ~ctx queue x in
13741377
let (py, cy), queue = access_queue' ~ctx queue y in
13751378
let e =
1376-
if is_int cx || is_int cy
1379+
if not (maybe_zero_or_nan cx && maybe_zero_or_nan cy)
13771380
then bool (J.EBin (J.NotEqEq, cx, cy))
13781381
else
13791382
bool_not

0 commit comments

Comments
 (0)