Repro for multiple declarations in for initializer codegen issue

This commit is contained in:
Joe Savona
2024-03-13 15:31:51 -07:00
parent 2940440dfb
commit fe29f46de8
3 changed files with 48 additions and 0 deletions
@@ -0,0 +1,38 @@
## Input
```javascript
function Component(props) {
const items = [];
for (let i = 0, length = props.items.length; i < length; i++) {
items.push(props.items[i]);
}
return items;
}
```
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(2);
let items;
if ($[0] !== props.items) {
items = [];
for (let i = 0; i < length; i++) {
items.push(props.items[i]);
}
$[0] = props.items;
$[1] = items;
} else {
items = $[1];
}
return items;
}
```
@@ -0,0 +1,9 @@
function Component(props) {
const items = [];
for (let i = 0, length = props.items.length; i < length; i++) {
items.push(props.items[i]);
}
return items;
}
@@ -535,6 +535,7 @@ const skipFilter = new Set([
"bug-jsx-memberexpr-tag-in-lambda",
"bug-invalid-code-when-bailout",
"component-syntax-ref-gating.flow",
"for-multiple-variable-declarations-in-initializer",
// 'react-forget-runtime' not yet supported
"flag-enable-emit-hook-guards",