-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.
Description
Version
v17.4.0
Platform
Darwin macbook-pro-5.lan 21.2.0 Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:54 PST 2021; root:xnu-8019.61.5~1/RELEASE_X86_64 x86_64
Subsystem
assert
What steps will reproduce the bug?
assert.deepEqual(new Proxy(['foo'], {}), ['foo']); // works properly
assert.deepEqual(new Proxy(['foo'], { ownKeys: (target) => Reflect.ownKeys(target) }), ['foo']) // throws
assert.deepStrictEqual(new Proxy(['foo'], {}), ['foo']); // works properly
assert.deepStrictEqual(new Proxy(['foo'], { ownKeys: (target) => Reflect.ownKeys(target) }), ['foo']) // throwsIn the above, Reflect.ownKeys(target) should be the same as not setting an ownKeys trap, but it isn't. The trap works fine elsewhere
Indeed,
Reflect.ownKeys(['foo']) // [ '0', 'length' ]
assert.deepEqual(new Proxy(['foo'], { ownKeys: (target) => ['0', 'length'] }), ['foo']) // throwsHow often does it reproduce? Is there a required condition?
Every time
What is the expected behavior?
Using a ownKeys trap shouldn't cause comparison errors.
The ownKeys trap seems to be working fine elsewhere. I traced the code to:
node/lib/internal/util/comparisons.js
Line 179 in dab8ab2
| const keys1 = getOwnNonIndexProperties(val1, filter); |
Where the
GetOwnNonIndexProperties function is called. Perhaps it is incorrectly filtering or the filtering is broken for proxies somehow?
What do you see instead?
Comparison errors from assert.deepEquals and assert.deepStrictEquals when the Arrays compared have the same content, but are using Proxies with ownKeys traps.
Additional information
I tried this on node 14, 16, and 17, with the same results.
Metadata
Metadata
Assignees
Labels
assertIssues and PRs related to the assert subsystem.Issues and PRs related to the assert subsystem.confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.utilIssues and PRs related to the built-in util module.Issues and PRs related to the built-in util module.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.