assert: fix TypeError on deepStrictEqual with null Map key or Set member · nodejs/node@e6832b2 · GitHub
Skip to content

Commit e6832b2

Browse files
semxaduh95
authored andcommitted
assert: fix TypeError on deepStrictEqual with null Map key or Set member
deepStrictEqual() and util.isDeepStrictEqual() threw "Cannot read properties of null (reading 'constructor')" instead of comparing when a Map key or Set member was null/undefined (or another primitive) and lined up against object-only keys/members in the other collection with an equal count. The primitive/null handling was gated behind an optimization that is skipped when the counts match, letting such keys reach objectComparisonStart, which dereferences `.constructor`. Resolve primitive and null keys/members directly in every case. Signed-off-by: semx <7532921+semx@users.noreply.github.com> PR-URL: #64449 Reviewed-By: Jordan Harband <ljharb@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent eff5d15 commit e6832b2

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎lib/internal/util/comparisons.js‎

Lines changed: 9 additions & 7 deletions

‎test/parallel/test-assert-deep.js‎

Lines changed: 15 additions & 0 deletions

0 commit comments

Comments
 (0)