fix(deepEqual): prevent null return breaking nested Promise/function comparisons#275
Merged
fix(deepEqual): prevent null return breaking nested Promise/function comparisons#275
Conversation
…comparisons Fixes issue from PR #273 where _deepEquals() returning null from _strictEquals for non-reference-equal Promises/functions/WeakMaps caused nested comparisons to fail incorrectly. Callers check (=== false), treating null as "equal". Two bugs fixed: 1. Added _strictEqualsBool wrapper to convert null → false for types that should only be equal if reference-equal (Promise, function, symbol, WeakMap, WeakSet) 2. Fixed _getTypeComparer() objType lookup bug where undefined objType accessed _typeEquals["undefined"] returning wrong comparer instead of falling back to theType Changes: - core/src/assert/funcs/equal.ts: * Added _strictEqualsBool wrapper function * Updated _typeEquals map for promise/function/symbol/weakmap/weakset * Fixed _getTypeComparer to check (objType && _typeEquals[objType]) - core/test/src/assert/assert.equals.test.ts: * Added regression test for Promise/function in nested objects/arrays
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes deep equality behavior in @nevware21/tripwire where _deepEquals() could return null for certain non-deep-comparable types (e.g., Promise/function) during nested comparisons, which callers incorrectly treated as “equal”. Also corrects type-comparer selection when objType is undefined.
Changes:
- Added a
_strictEqualsBoolwrapper so Promise/function/symbol/WeakMap/WeakSet comparisons never returnnull(non-reference-equal →false). - Fixed
_getTypeComparer()to avoid accidentally selecting the"undefined"comparer whenobjTypeis not present. - Added a regression test covering nested Promise/function comparisons in
deepStrictEqual.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/assert/funcs/equal.ts | Ensures strict-only types yield boolean results and fixes comparer lookup fallback logic. |
| core/test/src/assert/assert.equals.test.ts | Adds regression coverage for nested Promise/function mismatches under deepStrictEqual. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #275 +/- ##
=======================================
Coverage 91.43% 91.43%
=======================================
Files 78 78
Lines 3443 3445 +2
Branches 886 886
=======================================
+ Hits 3148 3150 +2
Misses 295 295
🚀 New features to boost your workflow:
|
nevware21-bot
approved these changes
Feb 12, 2026
Contributor
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes issue from PR #273 where _deepEquals() returning null from _strictEquals for non-reference-equal Promises/functions/WeakMaps caused nested comparisons to fail incorrectly. Callers check (=== false), treating null as "equal".
Two bugs fixed:
Changes: