Add reproduction for Equal issue - #6874
Conversation
🦋 Changeset detectedLatest commit: c6ccd50 The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
EqualNeverThrows.test.ts: Adds two reproduction tests confirmingEqual.equalsthrows for invalidDatevalues (RangeErrorfromtoISOString()inHash.hash) and forDataViewvalues (TypeErrorfrom iterating a non-iterable in thearray()hash path).
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
| @@ -0,0 +1,15 @@ | |||
| import { assert, describe, it } from "@effect/vitest" | |||
There was a problem hiding this comment.
Remove this test file and merge with the main one.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Date comparison: Switched from
toISOString()togetTime()with a NaN guard, so invalid dates no longer throw. - DataView comparison: Added a
compareDataViewshelper that wraps the DataView buffer inUint8Arraybefore delegating tocompareTypedArrays, with aDataViewinstance-of check to reject mixed-type pairs. - Hash module: Guarded
Date.prototype.toISOString()against NaN and added aDataView-specific branch that wraps the buffer inUint8Arraybefore callingarray(). - Tests: Consolidated reproduction tests into
Equal.test.ts, covering invalid-date equality and DataView byte comparison.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
| return true | ||
| } | ||
|
|
||
| function compareDataViews(self: DataView, that: DataView): boolean { |
There was a problem hiding this comment.
Considering this helper is only used in one place in-line it please.
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Fix
This PR adds reproduction tests and fixes the underlying
Equal.equalsandHash.hashhandling for invalid dates andDataViewvalues.Covered audit issues
1.
core-a-f-equal-dataview-throws: DataView comparison throws instead of comparing bytesModule:
EqualExpected contract: Equal.equals deeply compares supported objects and never throws; ArrayBuffer views enter the typed-array comparison path.
Observed result: A direct Node 24 source probe reproduced RangeError for invalid dates and TypeError for DataViews.
Reproduction command:
2.
core-a-f-equal-invalid-date-throws: Invalid dates violate Equal.equals never-throws contractModule:
EqualExpected contract: Equal.equals returns a boolean and never throws, including for JavaScript Date values.
Observed result: A direct Node 24 source probe reproduced RangeError for invalid dates and TypeError for DataViews.
Reproduction command:
Closes EFF-310