From a746121aa645365455f536e04a7f31cc45007df3 Mon Sep 17 00:00:00 2001 From: Rob Date: Sun, 22 Nov 2026 13:41:02 -0500 Subject: [PATCH 1/4] Add failing test: Fold `compare(a, b) 0` only for ints `compare(a, b) == 0`, `< 0` and `> 0` are folded to `a === b`, `a < b` and `a > b` for any type, not only ints, so structural comparison of records, tuples, arrays, options and NaN gives the wrong answer. Cause: compiler/backend/js_exp_make.ml:1539 (int_comp matches any runtime "compare") Signed-off-by: Rob --- tests/tests/src/compare_fold_test.mjs | 46 +++++++++++++++++++++++++++ tests/tests/src/compare_fold_test.res | 43 +++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 tests/tests/src/compare_fold_test.mjs create mode 100644 tests/tests/src/compare_fold_test.res diff --git a/tests/tests/src/compare_fold_test.mjs b/tests/tests/src/compare_fold_test.mjs new file mode 100644 index 0000000000..e22945dcf5 --- /dev/null +++ b/tests/tests/src/compare_fold_test.mjs @@ -0,0 +1,46 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE + +import * as Mocha from "mocha"; +import * as Test_utils from "./test_utils.mjs"; + +function id(x) { + return x; +} + +Mocha.describe("Compare_fold_test", () => { + Mocha.test("records", () => { + let a = id({ + x: 1 + }); + let b = id({ + x: 1 + }); + let c = id({ + x: 2 + }); + Test_utils.eq("File \"compare_fold_test.res\", line 20, characters 7-14", a === b, true); + Test_utils.eq("File \"compare_fold_test.res\", line 22, characters 7-14", a < c, true); + Test_utils.eq("File \"compare_fold_test.res\", line 24, characters 7-14", c > a, true); + }); + Mocha.test("tuples, arrays and options", () => { + Test_utils.eq("File \"compare_fold_test.res\", line 29, characters 7-14", id([ + 1, + 2 + ]) === id([ + 1, + 2 + ]), true); + Test_utils.eq("File \"compare_fold_test.res\", line 31, characters 7-14", id([10]) < id([9]), false); + Test_utils.eq("File \"compare_fold_test.res\", line 33, characters 7-14", id(undefined) < id(1), true); + }); + Mocha.test("NaN", () => { + let nan = id(NaN); + Test_utils.eq("File \"compare_fold_test.res\", line 39, characters 7-14", nan < id(1.0), true); + Test_utils.eq("File \"compare_fold_test.res\", line 41, characters 7-14", nan === nan, true); + }); +}); + +export { + id, +} +/* Not a pure module */ diff --git a/tests/tests/src/compare_fold_test.res b/tests/tests/src/compare_fold_test.res new file mode 100644 index 0000000000..d95157a3af --- /dev/null +++ b/tests/tests/src/compare_fold_test.res @@ -0,0 +1,43 @@ +open Mocha +open Test_utils + +/*** +`compare(a, b) == 0`, `< 0` and `> 0` are folded to `a === b`, `a < b` and +`a > b` for any type, not only ints, so structural comparison of records, +tuples, arrays, options and NaN gives the wrong answer. +*/ + +@inline(never) let id = x => x + +type point = {x: int} + +describe(__MODULE__, () => { + test("records", () => { + let a = id({x: 1}) + let b = id({x: 1}) + let c = id({x: 2}) + // Actual: false, expected: true + eq(__LOC__, compare(a, b) == 0, true) + // Actual: false, expected: true + eq(__LOC__, compare(a, c) < 0, true) + // Actual: false, expected: true + eq(__LOC__, compare(c, a) > 0, true) + }) + + test("tuples, arrays and options", () => { + // Actual: false, expected: true + eq(__LOC__, compare(id((1, 2)), id((1, 2))) == 0, true) + // Actual: true, expected: false + eq(__LOC__, compare(id([10]), id([9])) < 0, false) + // Actual: false, expected: true + eq(__LOC__, compare(id(None), id(Some(1))) < 0, true) + }) + + test("NaN", () => { + let nan = id(Float.Constants.nan) + // Actual: false, expected: true + eq(__LOC__, compare(nan, id(1.0)) < 0, true) + // Actual: false, expected: true + eq(__LOC__, compare(nan, nan) == 0, true) + }) +}) From c80d29f806f570016380e1dd776d5d50dadc03fc Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 23 Nov 2026 11:54:14 -0500 Subject: [PATCH 2/4] Fold compare against 0 only where JS operators agree int_comp rewrote any runtime call named "compare" compared with 0 into a direct JS comparison (compare(a, b) == 0 -> a === b, < 0 -> a < b, ...). The pattern ignored the runtime module, so Primitive_object.compare (structural) and Primitive_float.compare (NaN ordering) were folded too, giving wrong results for records, tuples, arrays, options and NaN. Only fold the compare of Primitive_int, Primitive_bool, Primitive_string and Primitive_bigint, whose results always agree with the JS operators. Signed-off-by: Rob --- compiler/core/js_exp_make.ml | 17 +++++++++--- tests/tests/src/caml_compare_bigint_test.mjs | 4 +-- tests/tests/src/compare_fold_test.mjs | 28 +++++++++++++------- tests/tests/src/compare_fold_test.res | 21 +++++++-------- tests/tests/src/test_list.mjs | 9 ++++--- 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/compiler/core/js_exp_make.ml b/compiler/core/js_exp_make.ml index 1babd208a3..3d6c863f12 100644 --- a/compiler/core/js_exp_make.ml +++ b/compiler/core/js_exp_make.ml @@ -1376,6 +1376,16 @@ let compare_int_aux (cmp : Lam_compat.comparison) (l : int) r = | Cle -> l <= r | Cge -> l >= r +(* [compare] of these runtime modules is a total order that agrees with the JS + operators, so [compare a b 0] is [a b]. Not so for + [Primitive_float] (NaN) nor [Primitive_object] (structural). *) +let compare_agrees_with_js_operators (module_id : J.module_id) = + let name = Ident.name module_id.id in + name = Primitive_modules.int + || name = Primitive_modules.bool + || name = Primitive_modules.string + || name = Primitive_modules.bigint + let rec int_comp (cmp : Lam_compat.comparison) ?comment (e0 : t) (e1 : t) = match (cmp, e0.expression_desc, e1.expression_desc) with | _, Number (Int {i = l}), Number (Int {i = r}) -> @@ -1385,12 +1395,13 @@ let rec int_comp (cmp : Lam_compat.comparison) ?comment (e0 : t) (e1 : t) = | ( _, Call ( { - expression_desc = Var (Qualified ({kind = Runtime}, Some "compare")); - _; + expression_desc = + Var (Qualified (({kind = Runtime} as module_id), Some "compare")); }, [l; r], _ ), - Number (Int {i = 0l}) ) -> + Number (Int {i = 0l}) ) + when compare_agrees_with_js_operators module_id -> int_comp cmp l r (* = 0 > 0 < 0 *) | (Ceq, Optional_block _, Undefined _ | Ceq, Undefined _, Optional_block _) when no_side_effect e0 && no_side_effect e1 -> diff --git a/tests/tests/src/caml_compare_bigint_test.mjs b/tests/tests/src/caml_compare_bigint_test.mjs index 4c00d5c600..d47ac2d84d 100644 --- a/tests/tests/src/caml_compare_bigint_test.mjs +++ b/tests/tests/src/caml_compare_bigint_test.mjs @@ -8,8 +8,8 @@ let five = BigInt("5"); Mocha.describe("Caml_compare_bigint_test", () => { Mocha.test("compare: 123 and 555555", () => { - Test_utils.ok("File \"caml_compare_bigint_test.res\", line 10, characters 7-14", BigInt("555555") > BigInt("123")); - Test_utils.ok("File \"caml_compare_bigint_test.res\", line 11, characters 7-14", BigInt("123") < BigInt("555555")); + Test_utils.ok("File \"caml_compare_bigint_test.res\", line 10, characters 7-14", Primitive_float.compare(BigInt("555555"), BigInt("123")) > 0); + Test_utils.ok("File \"caml_compare_bigint_test.res\", line 11, characters 7-14", Primitive_float.compare(BigInt("123"), BigInt("555555")) < 0); Test_utils.ok("File \"caml_compare_bigint_test.res\", line 12, characters 7-14", BigInt("123") < BigInt("555555")); Test_utils.ok("File \"caml_compare_bigint_test.res\", line 13, characters 7-14", BigInt("123") <= BigInt("555555")); Test_utils.ok("File \"caml_compare_bigint_test.res\", line 14, characters 7-14", BigInt("555555") > BigInt("123")); diff --git a/tests/tests/src/compare_fold_test.mjs b/tests/tests/src/compare_fold_test.mjs index e22945dcf5..6afc2537c0 100644 --- a/tests/tests/src/compare_fold_test.mjs +++ b/tests/tests/src/compare_fold_test.mjs @@ -2,6 +2,8 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; +import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.js"; +import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js"; function id(x) { return x; @@ -18,25 +20,31 @@ Mocha.describe("Compare_fold_test", () => { let c = id({ x: 2 }); - Test_utils.eq("File \"compare_fold_test.res\", line 20, characters 7-14", a === b, true); - Test_utils.eq("File \"compare_fold_test.res\", line 22, characters 7-14", a < c, true); - Test_utils.eq("File \"compare_fold_test.res\", line 24, characters 7-14", c > a, true); + Test_utils.eq("File \"compare_fold_test.res\", line 19, characters 7-14", Primitive_object.compare(a, b) === 0, true); + Test_utils.eq("File \"compare_fold_test.res\", line 20, characters 7-14", Primitive_object.compare(a, c) < 0, true); + Test_utils.eq("File \"compare_fold_test.res\", line 21, characters 7-14", Primitive_object.compare(c, a) > 0, true); }); Mocha.test("tuples, arrays and options", () => { - Test_utils.eq("File \"compare_fold_test.res\", line 29, characters 7-14", id([ + Test_utils.eq("File \"compare_fold_test.res\", line 25, characters 7-14", Primitive_object.compare(id([ 1, 2 - ]) === id([ + ]), id([ 1, 2 - ]), true); - Test_utils.eq("File \"compare_fold_test.res\", line 31, characters 7-14", id([10]) < id([9]), false); - Test_utils.eq("File \"compare_fold_test.res\", line 33, characters 7-14", id(undefined) < id(1), true); + ])) === 0, true); + Test_utils.eq("File \"compare_fold_test.res\", line 26, characters 7-14", Primitive_object.compare(id([10]), id([9])) < 0, false); + Test_utils.eq("File \"compare_fold_test.res\", line 27, characters 7-14", Primitive_object.compare(id(undefined), id(1)) < 0, true); }); Mocha.test("NaN", () => { let nan = id(NaN); - Test_utils.eq("File \"compare_fold_test.res\", line 39, characters 7-14", nan < id(1.0), true); - Test_utils.eq("File \"compare_fold_test.res\", line 41, characters 7-14", nan === nan, true); + Test_utils.eq("File \"compare_fold_test.res\", line 32, characters 7-14", Primitive_float.compare(nan, id(1.0)) < 0, true); + Test_utils.eq("File \"compare_fold_test.res\", line 33, characters 7-14", Primitive_float.compare(nan, nan) === 0, true); + }); + Mocha.test("primitives that fold", () => { + Test_utils.eq("File \"compare_fold_test.res\", line 37, characters 7-14", id(1) < id(2), true); + Test_utils.eq("File \"compare_fold_test.res\", line 38, characters 7-14", id("b") > id("a"), true); + Test_utils.eq("File \"compare_fold_test.res\", line 39, characters 7-14", id(true) === id(true), true); + Test_utils.eq("File \"compare_fold_test.res\", line 40, characters 7-14", id(2n) >= id(1n), true); }); }); diff --git a/tests/tests/src/compare_fold_test.res b/tests/tests/src/compare_fold_test.res index d95157a3af..c20d6b63fa 100644 --- a/tests/tests/src/compare_fold_test.res +++ b/tests/tests/src/compare_fold_test.res @@ -2,9 +2,9 @@ open Mocha open Test_utils /*** -`compare(a, b) == 0`, `< 0` and `> 0` are folded to `a === b`, `a < b` and -`a > b` for any type, not only ints, so structural comparison of records, -tuples, arrays, options and NaN gives the wrong answer. +`compare(a, b) 0` is folded to `a b` only where JS operators agree +with `compare` (int, bool, string, bigint); structural comparison of records, +tuples, arrays, options and NaN floats keeps calling the runtime. */ @inline(never) let id = x => x @@ -16,28 +16,27 @@ describe(__MODULE__, () => { let a = id({x: 1}) let b = id({x: 1}) let c = id({x: 2}) - // Actual: false, expected: true eq(__LOC__, compare(a, b) == 0, true) - // Actual: false, expected: true eq(__LOC__, compare(a, c) < 0, true) - // Actual: false, expected: true eq(__LOC__, compare(c, a) > 0, true) }) test("tuples, arrays and options", () => { - // Actual: false, expected: true eq(__LOC__, compare(id((1, 2)), id((1, 2))) == 0, true) - // Actual: true, expected: false eq(__LOC__, compare(id([10]), id([9])) < 0, false) - // Actual: false, expected: true eq(__LOC__, compare(id(None), id(Some(1))) < 0, true) }) test("NaN", () => { let nan = id(Float.Constants.nan) - // Actual: false, expected: true eq(__LOC__, compare(nan, id(1.0)) < 0, true) - // Actual: false, expected: true eq(__LOC__, compare(nan, nan) == 0, true) }) + + test("primitives that fold", () => { + eq(__LOC__, compare(id(1), id(2)) < 0, true) + eq(__LOC__, compare(id("b"), id("a")) > 0, true) + eq(__LOC__, compare(id(true), id(true)) == 0, true) + eq(__LOC__, compare(id(2n), id(1n)) >= 0, true) + }) }) diff --git a/tests/tests/src/test_list.mjs b/tests/tests/src/test_list.mjs index f83f1e404c..eb974bbe8f 100644 --- a/tests/tests/src/test_list.mjs +++ b/tests/tests/src/test_list.mjs @@ -2,6 +2,7 @@ import * as Belt_List from "@rescript/runtime/lib/es6/Belt_List.js"; import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.js"; +import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js"; function length_aux(_len, _x) { while (true) { @@ -361,7 +362,7 @@ function mem(x, _x_) { if (x_ === 0) { return false; } - if (x_.hd === x) { + if (Primitive_object.compare(x_.hd, x) === 0) { return true; } _x_ = x_.tl; @@ -388,7 +389,7 @@ function assoc(x, _x_) { let x_ = _x_; if (x_ !== 0) { let match = x_.hd; - if (match[0] === x) { + if (Primitive_object.compare(match[0], x) === 0) { return match[1]; } _x_ = x_.tl; @@ -425,7 +426,7 @@ function mem_assoc(x, _x_) { if (x_ === 0) { return false; } - if (x_.hd[0] === x) { + if (Primitive_object.compare(x_.hd[0], x) === 0) { return true; } _x_ = x_.tl; @@ -453,7 +454,7 @@ function remove_assoc(x, x_) { } let l = x_.tl; let pair = x_.hd; - if (pair[0] === x) { + if (Primitive_object.compare(pair[0], x) === 0) { return l; } else { return { From 007a1d69c459e615fc9e1a685690054d8eedd9c4 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 23 Nov 2026 13:12:54 -0500 Subject: [PATCH 3/4] Compare int constants as signed when folding compare int_comp folds a comparison of two int constants at compile time. It reads the left constant as unsigned and the right one as signed, so when the fold of compare(a, b) 0 recursed into it with a negative left constant, that constant became a large positive number: compare(-1, -1) == 0 folded to false and compare(-5, 3) > 0 to true. Plain comparisons such as -1 == -1 are folded earlier and were not affected. The unsigned read cannot simply be dropped here as on master: is_out compares (e >>> 0) > range through int_comp and relies on it for a constant e (gpr_3877_test). So the compare fold now compares two int constants as signed itself, and the general case is left alone. Also correct two comments: the one on compare_agrees_with_js_operators now says where the folded and the runtime result can differ (values JS cannot order), and the one in j.ml no longer says that the module of a runtime function can be ignored when matching on its name. Signed-off-by: Rob --- compiler/core/j.ml | 11 ++++------- compiler/core/js_exp_make.ml | 18 +++++++++++++----- tests/tests/src/compare_fold_test.mjs | 15 +++++++++++++++ tests/tests/src/compare_fold_test.res | 18 ++++++++++++++++++ 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/compiler/core/j.ml b/compiler/core/j.ml index dc5aa2514d..5fd05c06a7 100644 --- a/compiler/core/j.ml +++ b/compiler/core/j.ml @@ -61,13 +61,10 @@ and vident = Id of ident | Qualified of module_id * string option when the third one is None, it means the whole module TODO: - invariant, when [kind] is [Runtime], then we can ignore [ident], - since all [runtime] functions are unique, when do the - pattern match we can ignore the first one for simplicity - for example - {[ - Qualified (_, Runtime, Some "compare") - ]} + when [kind] is [Runtime], the name alone does not identify a function: + several runtime modules export the same name with different semantics, + such as [compare] of [Primitive_int], [Primitive_float] and + [Primitive_object]. Match on the module's [ident] as well. *) and exception_ident = ident diff --git a/compiler/core/js_exp_make.ml b/compiler/core/js_exp_make.ml index 3d6c863f12..40583a6f2d 100644 --- a/compiler/core/js_exp_make.ml +++ b/compiler/core/js_exp_make.ml @@ -1376,9 +1376,11 @@ let compare_int_aux (cmp : Lam_compat.comparison) (l : int) r = | Cle -> l <= r | Cge -> l >= r -(* [compare] of these runtime modules is a total order that agrees with the JS - operators, so [compare a b 0] is [a b]. Not so for - [Primitive_float] (NaN) nor [Primitive_object] (structural). *) +(* [compare] of these runtime modules agrees with the JS operators on + well-typed values, so [compare a b 0] is [a b]. Not so for + [Primitive_float] (NaN) nor [Primitive_object] (structural). Values that + JS cannot order, such as [null] and [undefined] constructors or a NaN typed + as an int, compare as greater at runtime and as unordered when folded. *) let compare_agrees_with_js_operators (module_id : J.module_id) = let name = Ident.name module_id.id in name = Primitive_modules.int @@ -1389,6 +1391,7 @@ let compare_agrees_with_js_operators (module_id : J.module_id) = let rec int_comp (cmp : Lam_compat.comparison) ?comment (e0 : t) (e1 : t) = match (cmp, e0.expression_desc, e1.expression_desc) with | _, Number (Int {i = l}), Number (Int {i = r}) -> + (* [is_out] relies on the left constant being read as unsigned *) let l = Ext_int.int32_unsigned_to_int l in let r = Int32.to_int r in bool (compare_int_aux cmp l r) @@ -1401,8 +1404,13 @@ let rec int_comp (cmp : Lam_compat.comparison) ?comment (e0 : t) (e1 : t) = [l; r], _ ), Number (Int {i = 0l}) ) - when compare_agrees_with_js_operators module_id -> - int_comp cmp l r (* = 0 > 0 < 0 *) + when compare_agrees_with_js_operators module_id -> ( + (* = 0 > 0 < 0 *) + match (l.expression_desc, r.expression_desc) with + | Number (Int {i = l}), Number (Int {i = r}) -> + (* both are signed here, unlike in the case above *) + bool (compare_int_aux cmp (Int32.to_int l) (Int32.to_int r)) + | _ -> int_comp cmp l r) | (Ceq, Optional_block _, Undefined _ | Ceq, Undefined _, Optional_block _) when no_side_effect e0 && no_side_effect e1 -> false_ diff --git a/tests/tests/src/compare_fold_test.mjs b/tests/tests/src/compare_fold_test.mjs index 6afc2537c0..90073477ea 100644 --- a/tests/tests/src/compare_fold_test.mjs +++ b/tests/tests/src/compare_fold_test.mjs @@ -45,6 +45,21 @@ Mocha.describe("Compare_fold_test", () => { Test_utils.eq("File \"compare_fold_test.res\", line 38, characters 7-14", id("b") > id("a"), true); Test_utils.eq("File \"compare_fold_test.res\", line 39, characters 7-14", id(true) === id(true), true); Test_utils.eq("File \"compare_fold_test.res\", line 40, characters 7-14", id(2n) >= id(1n), true); + Test_utils.eq("File \"compare_fold_test.res\", line 41, characters 7-14", id(1) !== id(1), false); + Test_utils.eq("File \"compare_fold_test.res\", line 42, characters 7-14", id(1) <= id(2), true); + }); + Mocha.test("negative int constants", () => { + Test_utils.eq("File \"compare_fold_test.res\", line 46, characters 7-14", true, true); + Test_utils.eq("File \"compare_fold_test.res\", line 47, characters 7-14", false, false); + Test_utils.eq("File \"compare_fold_test.res\", line 48, characters 7-14", true, true); + Test_utils.eq("File \"compare_fold_test.res\", line 49, characters 7-14", true, true); + Test_utils.eq("File \"compare_fold_test.res\", line 51, characters 7-14", true, true); + Test_utils.eq("File \"compare_fold_test.res\", line 52, characters 7-14", -1 === id(-1), true); + }); + Mocha.test("floats that are not NaN", () => { + Test_utils.eq("File \"compare_fold_test.res\", line 56, characters 7-14", Primitive_float.compare(id(1.5), id(2.5)) < 0, true); + Test_utils.eq("File \"compare_fold_test.res\", line 57, characters 7-14", Primitive_float.compare(id(2.5), id(2.5)) === 0, true); + Test_utils.eq("File \"compare_fold_test.res\", line 58, characters 7-14", Primitive_float.compare(id(-0.5), id(-1.5)) > 0, true); }); }); diff --git a/tests/tests/src/compare_fold_test.res b/tests/tests/src/compare_fold_test.res index c20d6b63fa..e08cffd84b 100644 --- a/tests/tests/src/compare_fold_test.res +++ b/tests/tests/src/compare_fold_test.res @@ -38,5 +38,23 @@ describe(__MODULE__, () => { eq(__LOC__, compare(id("b"), id("a")) > 0, true) eq(__LOC__, compare(id(true), id(true)) == 0, true) eq(__LOC__, compare(id(2n), id(1n)) >= 0, true) + eq(__LOC__, compare(id(1), id(1)) != 0, false) + eq(__LOC__, compare(id(1), id(2)) <= 0, true) + }) + + test("negative int constants", () => { + eq(__LOC__, compare(-1, -1) == 0, true) + eq(__LOC__, compare(-5, 3) > 0, false) + eq(__LOC__, compare(-5, 3) < 0, true) + eq(__LOC__, compare(3, -5) > 0, true) + let k = -1 + eq(__LOC__, compare(k, 0) <= 0, true) + eq(__LOC__, compare(-1, id(-1)) == 0, true) + }) + + test("floats that are not NaN", () => { + eq(__LOC__, compare(id(1.5), id(2.5)) < 0, true) + eq(__LOC__, compare(id(2.5), id(2.5)) == 0, true) + eq(__LOC__, compare(id(-0.5), id(-1.5)) > 0, true) }) }) From a9d99fad6d6557f0eeb5854df37b0df4694ae7b9 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 23 Nov 2026 13:38:43 -0500 Subject: [PATCH 4/4] Add CHANGELOG entry Signed-off-by: Rob --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb6a20bbe2..f1bc5a4c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Integer patterns that alias the same int32 value (e.g. `0xFFFF_FFFF` and `-1`) may now produce unused-case warnings. https://github.com/rescript-lang/rescript/pull/8717 https://github.com/rescript-lang/rescript/pull/8858 - Fix constant folding of a `switch` picking the wrong case for `@as(int)` constructors and for coerced variants. https://github.com/rescript-lang/rescript/pull/9318 - Fix constant folding of comparisons between `@as(int)` constructors and other constructors, and merging of switch arms returning them. https://github.com/rescript-lang/rescript/pull/9319 +- Fix `compare(a, b)` compared with `0` being folded into a JS comparison for records, tuples, arrays, options and floats, and folding to the wrong result for negative int constants. https://github.com/rescript-lang/rescript/pull/9401 #### :nail_care: Polish