Skip to content

Commit 4a47ce5

Browse files
BridgeARRafaelGSS
authored andcommitted
Revert "assert,util: revert recursive breaking change"
This reverts commit 575784b. PR-URL: #57622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 7d4db69 commit 4a47ce5

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

doc/api/assert.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,10 @@ An alias of [`assert.ok()`][].
556556
<!-- YAML
557557
added: v0.1.21
558558
changes:
559+
- version: REPLACEME
560+
pr-url: https://github.com/nodejs/node/pull/57622
561+
description: Recursion now stops when either side encounters a circular
562+
reference.
559563
- version:
560564
- v22.2.0
561565
- v20.15.0
@@ -632,7 +636,7 @@ are also recursively evaluated by the following rules.
632636
* [Object wrappers][] are compared both as objects and unwrapped values.
633637
* `Object` properties are compared unordered.
634638
* {Map} keys and {Set} items are compared unordered.
635-
* Recursion stops when both sides differ or both sides encounter a circular
639+
* Recursion stops when both sides differ or either side encounters a circular
636640
reference.
637641
* Implementation does not test the [`[[Prototype]]`][prototype-spec] of
638642
objects.
@@ -743,6 +747,10 @@ parameter is an instance of {Error} then it will be thrown instead of the
743747
<!-- YAML
744748
added: v1.2.0
745749
changes:
750+
- version: REPLACEME
751+
pr-url: https://github.com/nodejs/node/pull/57622
752+
description: Recursion now stops when either side encounters a circular
753+
reference.
746754
- version:
747755
- v22.2.0
748756
- v20.15.0
@@ -802,7 +810,7 @@ are recursively evaluated also by the following rules.
802810
* [Object wrappers][] are compared both as objects and unwrapped values.
803811
* `Object` properties are compared unordered.
804812
* {Map} keys and {Set} items are compared unordered.
805-
* Recursion stops when both sides differ or both sides encounter a circular
813+
* Recursion stops when both sides differ or either side encounters a circular
806814
reference.
807815
* {WeakMap} and {WeakSet} instances are **not** compared structurally.
808816
They are only equal if they reference the same object. Any comparison between

lib/internal/util/comparisons.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,10 @@ function keyCheck(val1, val2, mode, memos, iterationType, keys2) {
439439
if (memos.set === undefined) {
440440
if (memos.deep === false) {
441441
if (memos.a === val1) {
442-
if (memos.b === val2) return true;
442+
return memos.b === val2;
443+
}
444+
if (memos.b === val2) {
445+
return false;
443446
}
444447
memos.c = val1;
445448
memos.d = val2;
@@ -460,8 +463,8 @@ function keyCheck(val1, val2, mode, memos, iterationType, keys2) {
460463
const originalSize = set.size;
461464
set.add(val1);
462465
set.add(val2);
463-
if (originalSize === set.size) {
464-
return true;
466+
if (originalSize !== set.size - 2) {
467+
return originalSize === set.size;
465468
}
466469

467470
const areEq = objEquiv(val1, val2, mode, keys2, memos, iterationType);

test/parallel/test-assert-deep.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ test('GH-14441. Circular structures should be consistent', () => {
561561
b.a = {};
562562
b.a.a = a;
563563

564-
assertDeepAndStrictEqual(a, b);
564+
assertNotDeepOrStrict(a, b);
565565
}
566566

567567
{
@@ -571,7 +571,7 @@ test('GH-14441. Circular structures should be consistent', () => {
571571
b.a = b;
572572
const c = {};
573573
c.a = a;
574-
assertDeepAndStrictEqual(b, c);
574+
assertNotDeepOrStrict(b, c);
575575
}
576576

577577
{
@@ -581,7 +581,7 @@ test('GH-14441. Circular structures should be consistent', () => {
581581
b.add(b);
582582
const c = new Set();
583583
c.add(a);
584-
assertDeepAndStrictEqual(b, c);
584+
assertNotDeepOrStrict(b, c);
585585
}
586586
});
587587

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy