This repository was archived by the owner on Jul 23, 2021. It is now read-only.
This repository was archived by the owner on Jul 23, 2021. It is now read-only.
Inconsistency of value equality check of zero #153
Open
Description
From @balagge on Thu, 26 Sep 2019 08:36:12 GMT
What happened
using immutable.is()
if either operand is zero gives inconsistent / inconvenient results. Neither the built-in Number
objects, nor any custom value objects can ever be equal to 0
.
How to reproduce
is(new Number(1), 1); // true (as expected)
is(new Number(0), 0); // false (bug)
function myNumber(x) {this.x = x;}
myNumber.prototype.valueOf = function(){return this.x;}
is(new myNumber(1), 1); // true (as expected)
is(new myNumber(0), 0); // false (bug)
Cause
Following lines cause an early return (with false
) if any operand is zero:
Copied from original issue: immutable-js#1736