diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index b5d2d071479dec..523307aa29851b 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -502,8 +502,9 @@ function setEquiv(a, b, strict, memo) { for (const val of b) { // Primitive values have already been handled above. if (typeof val === 'object' && val !== null) { - if (!setHasEqualElement(set, val, strict, memo)) + if (!a.has(val) && !setHasEqualElement(set, val, strict, memo)) { return false; + } } else if (!strict && !a.has(val) && !setHasEqualElement(set, val, strict, memo)) { diff --git a/test/parallel/test-assert-deep.js b/test/parallel/test-assert-deep.js index 28f6bedfb8f54f..e94be7af1e6f23 100644 --- a/test/parallel/test-assert-deep.js +++ b/test/parallel/test-assert-deep.js @@ -375,7 +375,11 @@ assertOnlyDeepEqual( new Map([[undefined, null], ['+000', 2n]]), new Map([[null, undefined], [false, '2']]), ); - +const xarray = ['x']; +assertDeepAndStrictEqual( + new Set([xarray, ['y']]), + new Set([xarray, ['y']]) +); assertOnlyDeepEqual( new Set([null, '', 1n, 5, 2n, false]), new Set([undefined, 0, 5n, true, '2', '-000'])