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

util,assert: fix boxed primitives bug #22243

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/internal/util/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ function strictDeepEqual(val1, val2, memos) {
const val1Value = val1.valueOf();
// Note: Boxed string keys are going to be compared again by Object.keys
if (val1Value !== val1) {
if (typeof val2.valueOf !== 'function') {
return false;
}
if (!innerDeepEqual(val1Value, val2.valueOf(), true))
return false;
// Fast path for boxed primitives
Expand Down
7 changes: 7 additions & 0 deletions test/parallel/test-assert-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,3 +890,10 @@ assert.deepStrictEqual(obj1, obj2);
);
util.inspect.defaultOptions = tmp;
}

// Basic valueOf check.
{
const a = new String(1);
a.valueOf = undefined;
assertNotDeepOrStrict(a, new String(1));
}