mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
+38
@@ -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];
|
||||
```
|
||||
|
||||
|
||||
+17
@@ -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: [{}],
|
||||
};
|
||||
Reference in New Issue
Block a user