-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert,util: correct comparison when both contain same reference #53431
Conversation
Can you fix the commit message? The subsystem should be |
Co-authored-by: Chris Harvey <[email protected]>
@aduh95 Message reworded. |
@@ -502,7 +502,7 @@ 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 && |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which if
are you matching with which else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The else will be reached as it's the inner if. It could be optimized code wise (there is some duplication that can be prevented), but that could also be done in a later PR to check what implementation is best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lemire Oops, my bad, I was matching the else
on line 507 with the wrong if
, the one on line 505. Indentation is hard 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Co-authored-by: James M Snell <[email protected]>
Commit Queue failed- Loading data for nodejs/node/pull/53431 ✔ Done loading data for nodejs/node/pull/53431 ----------------------------------- PR info ------------------------------------ Title assert,util: correct comparison when both contain same reference (#53431) Author Daniel Lemire (@lemire) Branch lemire:verify_53423 -> nodejs:main Labels test, needs-ci Commits 2 - assert,util: correct comparison when both contain same reference - Update lib/internal/util/comparisons.js Committers 2 - Daniel Lemire - GitHub PR-URL: https://github.com/nodejs/node/pull/53431 Refs: https://github.com/nodejs/node/issues/53423 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Moshe Atlow Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/53431 Refs: https://github.com/nodejs/node/issues/53423 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Moshe Atlow Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca -------------------------------------------------------------------------------- ℹ This PR was created on Wed, 12 Jun 2024 15:04:11 GMT ✔ Approvals: 6 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/53431#pullrequestreview-2116256581 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/53431#pullrequestreview-2116361323 ✔ - Ruben Bridgewater (@BridgeAR) (TSC): https://github.com/nodejs/node/pull/53431#pullrequestreview-2116501755 ✔ - Moshe Atlow (@MoLow) (TSC): https://github.com/nodejs/node/pull/53431#pullrequestreview-2117085211 ✔ - Yagiz Nizipli (@anonrig): https://github.com/nodejs/node/pull/53431#pullrequestreview-2117118245 ✔ - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/53431#pullrequestreview-2119125467 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2024-06-17T08:10:36Z: https://ci.nodejs.org/job/node-test-pull-request/59827/ - Querying data for job/node-test-pull-request/59827/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 53431 From https://github.com/nodejs/node * branch refs/pull/53431/merge -> FETCH_HEAD ✔ Fetched commits as 2333573f3907..09449e7e728b -------------------------------------------------------------------------------- [main bf3d689d2c] assert,util: correct comparison when both contain same reference Author: Daniel Lemire Date: Wed Jun 12 11:00:46 2024 -0400 2 files changed, 6 insertions(+), 2 deletions(-) [main 2edda489f0] Update lib/internal/util/comparisons.js Author: Daniel Lemire Date: Fri Jun 14 09:57:10 2024 -0400 1 file changed, 2 insertions(+), 1 deletion(-) ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. Rebasing (2/4)https://github.com/nodejs/node/actions/runs/9548251230 |
Landed in ee5c6b6 |
Co-authored-by: Chris Harvey <[email protected]> PR-URL: #53431 Refs: #53423 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Co-authored-by: Chris Harvey <[email protected]> PR-URL: nodejs#53431 Refs: nodejs#53423 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Co-authored-by: Chris Harvey <[email protected]> PR-URL: nodejs#53431 Refs: nodejs#53423 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
@targos this seems like a critical bug fix… shouldn’t it go in an LTS version, v20? |
Co-authored-by: Chris Harvey <[email protected]> PR-URL: #53431 Refs: #53423 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
Co-authored-by: Chris Harvey <[email protected]> PR-URL: #53431 Refs: #53423 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
responding to my own comment above … this is in LTS v20 as per 20.16 changelog |
I would expect that given
Then
new Set([xarray, ['y']])
andnew Set([xarray, ['y']])
are equal as perassert.deepStrictEqual
but since Node 20, they are not.This PR applies the fix proposed by @BridgeAR
Refs: #53423 reported by @chharvey