Skip to content

fix: preserve symbols in intermediate patch paths - #1369

Open
Aryangupta-05 wants to merge 1 commit into
immerjs:mainfrom
Aryangupta-05:fix/replay-symbol-patch-paths
Open

Aryangupta-05 wants to merge 1 commit into
immerjs:mainfrom
Aryangupta-05:fix/replay-symbol-patch-paths

Conversation

@Aryangupta-05

Copy link
Copy Markdown

Refs #1367 (case B).

produceWithPatches can generate a nested path containing a symbol, but replaying it throws TypeError: Cannot convert a Symbol value to a string. Intermediate path traversal coerces symbols with "" + p before looking up the property.

Keep symbol path segments intact, alongside strings and numbers. Six regression cases cover objects, immerable classes with non-enumerable symbol properties, forward/inverse replay, distinct symbols with the same description, and both auto-freeze settings. The original state and class prototype are checked as well.

Validation on Windows with Node 24.22.1:

  • All six new cases fail on unchanged main (784c86b) with the reported TypeError.
  • yarn test: 4,219 source tests and 3,668 production-build tests passed (8 existing skips in each run); build and Flow passed.
  • yarn coverage and yarn test:perf passed.
  • Prettier checked the changed files; the pre-commit hook passed.

This addresses symbol traversal in case B only. Map-key preservation in #1312, patch-value cloning in #1354, and the Set identity question in case C are separate.

AI assistance: Codex investigated, implemented, reviewed, and ran the checks for this patch.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant