Add with helper for immutable rule updates#92
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| with(updates: Partial<ManualOpts>): RRuleTemporal { | ||
| const merged = { | ||
| ...this.cloneOptions(), | ||
| ...updates, | ||
| tzid: updates.tzid ?? this.opts.tzid, |
There was a problem hiding this comment.
Clone update arrays to keep with() immutable
The new with() helper spreads updates directly into merged, so array fields provided by the caller are stored by reference. This is observable for fields that the constructor does not sanitize/clone (notably rDate and exDate): if a caller does const r = rule.with({rDate}); rDate.push(...), the updated rule’s options mutate after construction, which violates the stated immutability goal and can change subsequent recurrence results. Consider cloning array-valued updates (or specifically rDate/exDate) before constructing the new instance.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
…lendar support for RSCALE. Enhance tests for immutability of rDate and exDate arrays.
Summary
Testing
Codex Task
Note
Introduces immutable rule updates and strengthens RSCALE handling.
with(updates)toRRuleTemporal, merging updates over cloned option arrays viacloneOptions/cloneUpdateOptionsto avoid shared referencesrscaleCalendarSupportandassertRscaleCalendarSupported, invoked before RSCALE enginesrfc7529_rscale_non_gregorian.test.ts(with calendar support probing) andrrule-temporal.test.tscases validatingwith()immutability and rDate/exDate cloningWritten by Cursor Bugbot for commit dee921e. This will update automatically on new commits. Configure here.