Skip to content

[compiler] Refine Object.fromEntries mutation effects - #38192

Open
magic-akari wants to merge 2 commits into
react:mainfrom
magic-akari:fix/compiler/object-fromentries-capture
Open

magic-akari wants to merge 2 commits into
react:mainfrom
magic-akari:fix/compiler/object-fromentries-capture

Conversation

@magic-akari

Copy link
Copy Markdown
Contributor

Conservative mutation effects for Object.fromEntries merge safe local entry arrays, their results, and downstream consumers into one reactive scope.

Refine both compilers to use capture effects for local entry arrays proven to have primitive keys and no potentially mutating uses. Preserve conditional mutation effects for other inputs so iterator consumption and key conversion remain correct across renders.

magic-akari and others added 2 commits November 10, 2026 23:39
Object.fromEntries reads its iterable and captures entry values into the
returned object. Modeling it as conditionally mutating the iterable merged
the argument, result, and consumers into one reactive scope.

Use Capture with a Create/Capture aliasing signature in both compilers so
these values can have independent reactive scopes.

Fixes react#34232

Co-authored-by: lauren <lauren@anysphere.co>
Object.fromEntries can consume its iterator and invoke object-key conversion.
Treating every input as capture can cache mutated state across renders.

Keep conditional transitive mutation in the default signature. Refine it to
capture for local entries arrays whose primitive keys and alias uses prove
that evaluation cannot mutate them.
@meta-cla meta-cla Bot added the CLA Signed label Nov 10, 2026
@magic-akari
magic-akari marked this pull request as ready for review November 10, 2026 18:21

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Compiler Bug]: Object.fromEntries() does not mutate

2 participants