Repository: facebook/react
Pull request: [compiler] Fix assignment within for update expression

Stack from [ghstack](https://github.com/ezyang/ghstack) (oldest at bottom):
* __->__ #30067

When converting value blocks from HIR to ReactiveFunction, we have to drop StoreLocal assignments that represent the assignment of the phi, since ReactiveFunction supports compound expressions. These StoreLocals are only present to represent the conditional assignment of the value itself - but it's also possible for the expression to have contained an assignment expression. Before, in trying to strip the first category of StoreLocal we also accidentally stripped the second category. Now we check that the assignment is for a temporary, and don't strip otherwise.

Changed files:
filename: compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts
patch: @@ -924,13 +924,15 @@ class Driver {
         let place: Place = instr.lvalue;
         let value: ReactiveValue = instr.value;
         if (
-          // Value blocks generally end in a StoreLocal to assign the value of the
-          // expression for this branch. These StoreLocal instructions can be pruned,
-          // since we represent the value blocks as a compund value in ReactiveFunction
-          // (no phis). However, it's also possible to have a value block that ends in
-          // an AssignmentExpression, which we need to keep. So we only prune
-          // StoreLocal for temporaries — any named/promoted values must be used
-          // elsewhere and aren't safe to prune.
+          /*
+           * Value blocks generally end in a StoreLocal to assign the value of the
+           * expression for this branch. These StoreLocal instructions can be pruned,
+           * since we represent the value blocks as a compund value in ReactiveFunction
+           * (no phis). However, it's also possible to have a value block that ends in
+           * an AssignmentExpression, which we need to keep. So we only prune
+           * StoreLocal for temporaries — any named/promoted values must be used
+           * elsewhere and aren't safe to prune.
+           */
           value.kind === "StoreLocal" &&
           value.lvalue.place.identifier.name === null
         ) {
@@ -952,13 +954,15 @@ class Driver {
         let place: Place = instr.lvalue;
         let value: ReactiveValue = instr.value;
         if (
-          // Value blocks generally end in a StoreLocal to assign the value of the
-          // expression for this branch. These StoreLocal instructions can be pruned,
-          // since we represent the value blocks as a compund value in ReactiveFunction
-          // (no phis). However, it's also possible to have a value block that ends in
-          // an AssignmentExpression, which we need to keep. So we only prune
-          // StoreLocal for temporaries — any named/promoted values must be used
-          // elsewhere and aren't safe to prune.
+          /*
+           * Value blocks generally end in a StoreLocal to assign the value of the
+           * expression for this branch. These StoreLocal instructions can be pruned,
+           * since we represent the value blocks as a compund value in ReactiveFunction
+           * (no phis). However, it's also possible to have a value block that ends in
+           * an AssignmentExpression, which we need to keep. So we only prune
+           * StoreLocal for temporaries — any named/promoted values must be used
+           * elsewhere and aren't safe to prune.
+           */
           value.kind === "StoreLocal" &&
           value.lvalue.place.identifier.name === null
         ) {