[test cases] Add failing / bug tests for destructuring assignment

This commit is contained in:
Mofei Zhang
2023-05-12 12:48:18 -04:00
parent fe95b5df90
commit dda3e61347
4 changed files with 66 additions and 0 deletions
@@ -0,0 +1,29 @@
## Input
```javascript
function useFoo(props) {
[x] = props;
return { x };
}
```
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react";
function useFoo(props) {
const $ = useMemoCache(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = { x };
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}
```
@@ -0,0 +1,4 @@
function useFoo(props) {
[x] = props;
return { x };
}
@@ -0,0 +1,24 @@
## Input
```javascript
function useFoo(props) {
let x;
[x] = props;
const foo = () => {
x = getX(props);
};
foo();
return { x };
}
```
## Error
```
[InferReferenceEffects] Context variables are always mutable.
```
@@ -0,0 +1,9 @@
function useFoo(props) {
let x;
[x] = props;
const foo = () => {
x = getX(props);
};
foo();
return { x };
}