Fixture for reassignment within value block

Fixture from T175283039, a reassignment within an expression can sometimes 
generate a StoreLocal within a value block. Depending on the case this can end 
up as the last instruction of the block, which then hits an invariant.
This commit is contained in:
Joe Savona
2024-03-08 13:59:21 -08:00
parent 052f5fe973
commit 5f3ed3f724
2 changed files with 55 additions and 0 deletions
@@ -0,0 +1,38 @@
## Input
```javascript
import { makeArray } from "shared-runtime";
// @flow
function Component() {
const items = makeArray(0, 1, 2);
let item;
let sum = 0;
while ((item = items.pop())) {
sum += item;
}
return [sum];
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
};
```
## Error
```
6 | let item;
7 | let sum = 0;
> 8 | while ((item = items.pop())) {
| ^^^^ [ReactForget] Invariant: Unexpected StoreLocal in codegenInstructionValue (8:8)
9 | sum += item;
10 | }
11 | return [sum];
```
@@ -0,0 +1,17 @@
import { makeArray } from "shared-runtime";
// @flow
function Component() {
const items = makeArray(0, 1, 2);
let item;
let sum = 0;
while ((item = items.pop())) {
sum += item;
}
return [sum];
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{}],
};