Skip to content
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
@Methuselah96

Description

@Methuselah96

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:

https://github.com/immutable-js/immutable-js/blob/e65e5af806ea23a32ccf8f56c6fabf39605bac80/src/is.js#L68-L70

Copied from original issue: immutable-js#1736

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions