Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Inconsistency of value equality check of zero #153

Open
Methuselah96 opened this issue Oct 17, 2020 · 0 comments
Open

Inconsistency of value equality check of zero #153

Methuselah96 opened this issue Oct 17, 2020 · 0 comments
Labels
bug Something isn't working from-original-repo
Milestone

Comments

@Methuselah96
Copy link

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

@Methuselah96 Methuselah96 added the bug Something isn't working label Oct 31, 2020
@Methuselah96 Methuselah96 added this to the 4.0 milestone Oct 31, 2020
@Methuselah96 Methuselah96 modified the milestones: 4.0, 4.1 Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working from-original-repo
Projects
None yet
Development

No branches or pull requests

1 participant