You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Float constants never compare equal in the JS simplifier: x == 2.5 && x == 2.5 compiles to false #9099
An int constant and a float constant with the same value are also treated as different. In an untagged variant this sends a literal case to the wrong arm:
The compiler warns that 1 is always matched as L1, never as N, yet emits:
functionf(v){if(v!==1.0){return6;}else{return4;}}
so f(L1) returns 4 at run time, where the warning says it should return 6. @as(2.5) L | N(float) with N(2.5) behaves the same way. All of these reproduce at b123b7c3 as well.
Cause
Js_analyzer.eq_expression returns false for any two Number (Float _), and compares Number (Int _) only with another Int. The rules in simplify_and_ take "not eq_expression" to mean "different constants". So x === c1 && x === c2 becomes false, and x !== c1 && x === c2 becomes x === c2. Under JS ===, equal float literals are equal, and so are 1 and 1.0.
Activity
Compare literals by value when simplifying equality conjunctions (#9114)