Skip to content

Preserve postfix member update values in nested functions#36390

Open
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/compiler-post-increment-assignment
Open

Preserve postfix member update values in nested functions#36390
raashish1601 wants to merge 1 commit intofacebook:mainfrom
raashish1601:codex/compiler-post-increment-assignment

Conversation

@raashish1601
Copy link
Copy Markdown

Summary

  • run temporary promotion when nested function/object-method codegen rebuilds a reactive function
  • rename newly promoted nested temporaries before emitting nested code
  • add a callback/member postfix regression fixture and update the existing ref postfix fixture

Why

Nested function expressions are rebuilt into reactive functions during codegen. They pruned unused lvalues but skipped the promotion pass that preserves temporaries across interposed side-effecting statements, so postfix member updates like agg.itemCounter++ could read the value after the write.

Fixes #35205.

Test Plan

  • corepack yarn workspace snap run snap --update --pattern "{bug-ref-prefix-postfix-operator,postfix-member-assignment-in-callback}" --sync
  • corepack yarn workspace snap run snap --pattern "{bug-ref-prefix-postfix-operator,postfix-member-assignment-in-callback}" --sync
  • corepack yarn workspace babel-plugin-react-compiler run lint -- --quiet
  • corepack yarn prettier

Note: corepack yarn workspace snap run snap --pattern member-inc --sync produced identical generated code but failed on CRLF/LF snapshot text in this Windows checkout, so I did not update that unrelated fixture.

@meta-cla meta-cla Bot added the CLA Signed label May 2, 2026
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]: Post Increment Assignment Compiling to Pre Increment Assignment

1 participant