fix: draft relocated base refs after reverse/sort in array-methods plugin (#1255)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
With enableArrayMethods(), reverse() and sort() run natively on copy_, which still holds raw base references. Reordering relocates an un-drafted base object to an index where it no longer equals base_[prop], so the get trap's positional check misses it and returns the raw base object. Writing to that object mutates the user's base state, violating immer's guarantee that the base state is never modified. Patches and inverse patches are wrong too. Detect a relocated base reference in the get trap (only after a reorder, for indices the user did not explicitly assign) and draft it before exposing it.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+58 added−2 removed
- tests:+33 added−1 removed
- other:+25 added−1 removed