Compare literals by JavaScript value when simplifying x === c1 && x === c2
Why
The simplifier read "not eq_expression" as "different constants", but eq_expression never equates float literals, nor an int with a float. So x === 2.5 && x === 2.5 became false, and an untagged case whose payload literal equals a literal tag (@as(1) L1 | N(float), N(1.0)) went to the wrong arm. Js_analyzer.eq_literal now decides literal equality as === does, and the rules apply only when it knows.
modifiedJS and-simplification of literal comparisons
let a = (x: float) => x == 2.5 && x == 2.5let b = (x: float) => x != 2.5 && x == 2.5@unboxed type t = @as(1) L1 | N(float) | S(string)let f = (v: t) => switch v { | N(1.0) => 4 | _ => 6 }
js
Before
After
function a(x) {function a(x) { return false; return x === 2.5;}}function b(x) {function b(x) { return x === 2.5; return false;}}function f(v) {function f(v) { if (v !== 1.0) { return 6; } else { return 4; } return 6; }}