mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
[compiler] Update fixtures for new inference (#33496)
--- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33496). * #33571 * #33558 * #33547 * #33543 * #33533 * #33532 * #33530 * #33526 * #33522 * #33518 * #33514 * #33513 * #33512 * #33504 * #33500 * #33497 * __->__ #33496
This commit is contained in:
parent
df080d228b
commit
0cf6d0c929
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {
|
||||
Stringify,
|
||||
mutate,
|
||||
|
|
@ -101,7 +102,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import {
|
||||
Stringify,
|
||||
mutate,
|
||||
|
|
@ -175,21 +176,14 @@ import {
|
|||
* and mutability.
|
||||
*/
|
||||
function Component(t0) {
|
||||
const $ = _c(4);
|
||||
const $ = _c(2);
|
||||
const { prop } = t0;
|
||||
let t1;
|
||||
if ($[0] !== prop) {
|
||||
const obj = shallowCopy(prop);
|
||||
const aliasedObj = identity(obj);
|
||||
let t2;
|
||||
if ($[2] !== obj) {
|
||||
t2 = [obj.id];
|
||||
$[2] = obj;
|
||||
$[3] = t2;
|
||||
} else {
|
||||
t2 = $[3];
|
||||
}
|
||||
const id = t2;
|
||||
|
||||
const id = [obj.id];
|
||||
|
||||
mutate(aliasedObj);
|
||||
setPropertyByKey(aliasedObj, "id", prop.id + 1);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {
|
||||
Stringify,
|
||||
mutate,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {Stringify} from 'shared-runtime';
|
||||
|
||||
/**
|
||||
|
|
@ -43,7 +44,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
/**
|
||||
|
|
@ -57,62 +58,67 @@ import { Stringify } from "shared-runtime";
|
|||
* - cb1 is not assumed to be called since it's only used as a call operand
|
||||
*/
|
||||
function useFoo(t0) {
|
||||
const $ = _c(13);
|
||||
const { arr1, arr2 } = t0;
|
||||
const $ = _c(14);
|
||||
let arr1;
|
||||
let arr2;
|
||||
let t1;
|
||||
if ($[0] !== arr1[0]) {
|
||||
t1 = (e) => arr1[0].value + e.value;
|
||||
$[0] = arr1[0];
|
||||
$[1] = t1;
|
||||
if ($[0] !== t0) {
|
||||
({ arr1, arr2 } = t0);
|
||||
let t2;
|
||||
if ($[4] !== arr1[0]) {
|
||||
t2 = (e) => arr1[0].value + e.value;
|
||||
$[4] = arr1[0];
|
||||
$[5] = t2;
|
||||
} else {
|
||||
t2 = $[5];
|
||||
}
|
||||
const cb1 = t2;
|
||||
t1 = () => arr1.map(cb1);
|
||||
$[0] = t0;
|
||||
$[1] = arr1;
|
||||
$[2] = arr2;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
arr1 = $[1];
|
||||
arr2 = $[2];
|
||||
t1 = $[3];
|
||||
}
|
||||
const cb1 = t1;
|
||||
const getArrMap1 = t1;
|
||||
let t2;
|
||||
if ($[2] !== arr1 || $[3] !== cb1) {
|
||||
t2 = () => arr1.map(cb1);
|
||||
$[2] = arr1;
|
||||
$[3] = cb1;
|
||||
$[4] = t2;
|
||||
if ($[6] !== arr2) {
|
||||
t2 = (e_0) => arr2[0].value + e_0.value;
|
||||
$[6] = arr2;
|
||||
$[7] = t2;
|
||||
} else {
|
||||
t2 = $[4];
|
||||
t2 = $[7];
|
||||
}
|
||||
const getArrMap1 = t2;
|
||||
const cb2 = t2;
|
||||
let t3;
|
||||
if ($[5] !== arr2) {
|
||||
t3 = (e_0) => arr2[0].value + e_0.value;
|
||||
$[5] = arr2;
|
||||
$[6] = t3;
|
||||
if ($[8] !== arr1 || $[9] !== cb2) {
|
||||
t3 = () => arr1.map(cb2);
|
||||
$[8] = arr1;
|
||||
$[9] = cb2;
|
||||
$[10] = t3;
|
||||
} else {
|
||||
t3 = $[6];
|
||||
t3 = $[10];
|
||||
}
|
||||
const cb2 = t3;
|
||||
const getArrMap2 = t3;
|
||||
let t4;
|
||||
if ($[7] !== arr1 || $[8] !== cb2) {
|
||||
t4 = () => arr1.map(cb2);
|
||||
$[7] = arr1;
|
||||
$[8] = cb2;
|
||||
$[9] = t4;
|
||||
} else {
|
||||
t4 = $[9];
|
||||
}
|
||||
const getArrMap2 = t4;
|
||||
let t5;
|
||||
if ($[10] !== getArrMap1 || $[11] !== getArrMap2) {
|
||||
t5 = (
|
||||
if ($[11] !== getArrMap1 || $[12] !== getArrMap2) {
|
||||
t4 = (
|
||||
<Stringify
|
||||
getArrMap1={getArrMap1}
|
||||
getArrMap2={getArrMap2}
|
||||
shouldInvokeFns={true}
|
||||
/>
|
||||
);
|
||||
$[10] = getArrMap1;
|
||||
$[11] = getArrMap2;
|
||||
$[12] = t5;
|
||||
$[11] = getArrMap1;
|
||||
$[12] = getArrMap2;
|
||||
$[13] = t4;
|
||||
} else {
|
||||
t5 = $[12];
|
||||
t4 = $[13];
|
||||
}
|
||||
return t5;
|
||||
return t4;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {Stringify} from 'shared-runtime';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
let x = [a];
|
||||
let y = {};
|
||||
|
|
@ -23,19 +24,27 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
const $ = _c(2);
|
||||
let y;
|
||||
const $ = _c(4);
|
||||
let t0;
|
||||
if ($[0] !== a) {
|
||||
const x = [a];
|
||||
t0 = [a];
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const x = t0;
|
||||
let y;
|
||||
if ($[2] !== x[0][1]) {
|
||||
y = {};
|
||||
|
||||
y = x[0][1];
|
||||
$[0] = a;
|
||||
$[1] = y;
|
||||
$[2] = x[0][1];
|
||||
$[3] = y;
|
||||
} else {
|
||||
y = $[1];
|
||||
y = $[3];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
let x = [a];
|
||||
let y = {};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function bar(a, b) {
|
||||
let x = [a, b];
|
||||
let y = {};
|
||||
|
|
@ -27,22 +28,31 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
function bar(a, b) {
|
||||
const $ = _c(3);
|
||||
let y;
|
||||
const $ = _c(6);
|
||||
let t0;
|
||||
if ($[0] !== a || $[1] !== b) {
|
||||
const x = [a, b];
|
||||
t0 = [a, b];
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = t0;
|
||||
} else {
|
||||
t0 = $[2];
|
||||
}
|
||||
const x = t0;
|
||||
let y;
|
||||
if ($[3] !== x[0][1] || $[4] !== x[1][0]) {
|
||||
y = {};
|
||||
let t = {};
|
||||
|
||||
y = x[0][1];
|
||||
t = x[1][0];
|
||||
$[0] = a;
|
||||
$[1] = b;
|
||||
$[2] = y;
|
||||
$[3] = x[0][1];
|
||||
$[4] = x[1][0];
|
||||
$[5] = y;
|
||||
} else {
|
||||
y = $[2];
|
||||
y = $[5];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function bar(a, b) {
|
||||
let x = [a, b];
|
||||
let y = {};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
let x = [a];
|
||||
let y = {};
|
||||
|
|
@ -23,19 +24,27 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
const $ = _c(2);
|
||||
let y;
|
||||
const $ = _c(4);
|
||||
let t0;
|
||||
if ($[0] !== a) {
|
||||
const x = [a];
|
||||
t0 = [a];
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const x = t0;
|
||||
let y;
|
||||
if ($[2] !== x[0].a[1]) {
|
||||
y = {};
|
||||
|
||||
y = x[0].a[1];
|
||||
$[0] = a;
|
||||
$[1] = y;
|
||||
$[2] = x[0].a[1];
|
||||
$[3] = y;
|
||||
} else {
|
||||
y = $[1];
|
||||
y = $[3];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
let x = [a];
|
||||
let y = {};
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
let x = [a];
|
||||
let y = {};
|
||||
|
|
@ -22,19 +23,27 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
const $ = _c(2);
|
||||
let y;
|
||||
const $ = _c(4);
|
||||
let t0;
|
||||
if ($[0] !== a) {
|
||||
const x = [a];
|
||||
t0 = [a];
|
||||
$[0] = a;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const x = t0;
|
||||
let y;
|
||||
if ($[2] !== x[0]) {
|
||||
y = {};
|
||||
|
||||
y = x[0];
|
||||
$[0] = a;
|
||||
$[1] = y;
|
||||
$[2] = x[0];
|
||||
$[3] = y;
|
||||
} else {
|
||||
y = $[1];
|
||||
y = $[3];
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function bar(a) {
|
||||
let x = [a];
|
||||
let y = {};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @validateNoImpureFunctionsInRender
|
||||
// @validateNoImpureFunctionsInRender @enableNewMutationAliasingModel
|
||||
|
||||
function Component() {
|
||||
const date = Date.now();
|
||||
|
|
@ -20,7 +20,7 @@ function Component() {
|
|||
2 |
|
||||
3 | function Component() {
|
||||
> 4 | const date = Date.now();
|
||||
| ^^^^^^^^ InvalidReact: Calling an impure function can produce unstable results. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent). `Date.now` is an impure function whose results may change on every call (4:4)
|
||||
| ^^^^^^^^^^ InvalidReact: Calling an impure function can produce unstable results. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent). `Date.now` is an impure function whose results may change on every call (4:4)
|
||||
|
||||
InvalidReact: Calling an impure function can produce unstable results. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent). `performance.now` is an impure function whose results may change on every call (5:5)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @validateNoImpureFunctionsInRender
|
||||
// @validateNoImpureFunctionsInRender @enableNewMutationAliasingModel
|
||||
|
||||
function Component() {
|
||||
const date = Date.now();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function Component() {
|
||||
let local;
|
||||
|
||||
|
|
@ -41,13 +42,13 @@ function Component() {
|
|||
## Error
|
||||
|
||||
```
|
||||
3 |
|
||||
4 | const reassignLocal = newValue => {
|
||||
> 5 | local = newValue;
|
||||
| ^^^^^ InvalidReact: Reassigning a variable after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead. Variable `local` cannot be reassigned after render (5:5)
|
||||
6 | };
|
||||
7 |
|
||||
8 | const onClick = newValue => {
|
||||
4 |
|
||||
5 | const reassignLocal = newValue => {
|
||||
> 6 | local = newValue;
|
||||
| ^^^^^ InvalidReact: Reassigning a variable after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead. Variable `local` cannot be reassigned after render (6:6)
|
||||
7 | };
|
||||
8 |
|
||||
9 | const onClick = newValue => {
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function Component() {
|
||||
let local;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function useHook(a, b) {
|
||||
b.test = 1;
|
||||
a.test = 2;
|
||||
|
|
@ -13,12 +14,15 @@ function useHook(a, b) {
|
|||
## Error
|
||||
|
||||
```
|
||||
1 | function useHook(a, b) {
|
||||
> 2 | b.test = 1;
|
||||
| ^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead (2:2)
|
||||
3 | a.test = 2;
|
||||
4 | }
|
||||
5 |
|
||||
1 | // @enableNewMutationAliasingModel
|
||||
2 | function useHook(a, b) {
|
||||
> 3 | b.test = 1;
|
||||
| ^ InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead (3:3)
|
||||
|
||||
InvalidReact: Mutating component props or hook arguments is not allowed. Consider using a local variable instead (4:4)
|
||||
4 | a.test = 2;
|
||||
5 | }
|
||||
6 |
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function useHook(a, b) {
|
||||
b.test = 1;
|
||||
a.test = 2;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
let x = {a: 42};
|
||||
|
||||
function Component(props) {
|
||||
|
|
@ -17,13 +18,15 @@ function Component(props) {
|
|||
## Error
|
||||
|
||||
```
|
||||
3 | function Component(props) {
|
||||
4 | foo(() => {
|
||||
> 5 | x.a = 10;
|
||||
| ^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect (5:5)
|
||||
6 | x.a = 20;
|
||||
7 | });
|
||||
8 | }
|
||||
4 | function Component(props) {
|
||||
5 | foo(() => {
|
||||
> 6 | x.a = 10;
|
||||
| ^ InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect (6:6)
|
||||
|
||||
InvalidReact: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect (7:7)
|
||||
7 | x.a = 20;
|
||||
8 | });
|
||||
9 | }
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
let x = {a: 42};
|
||||
|
||||
function Component(props) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function Component() {
|
||||
const foo = () => {
|
||||
// Cannot assign to globals
|
||||
|
|
@ -17,13 +18,15 @@ function Component() {
|
|||
## Error
|
||||
|
||||
```
|
||||
2 | const foo = () => {
|
||||
3 | // Cannot assign to globals
|
||||
> 4 | someUnknownGlobal = true;
|
||||
| ^^^^^^^^^^^^^^^^^ InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (4:4)
|
||||
5 | moduleLocal = true;
|
||||
6 | };
|
||||
7 | foo();
|
||||
3 | const foo = () => {
|
||||
4 | // Cannot assign to globals
|
||||
> 5 | someUnknownGlobal = true;
|
||||
| ^^^^^^^^^^^^^^^^^ InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (5:5)
|
||||
|
||||
InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (6:6)
|
||||
6 | moduleLocal = true;
|
||||
7 | };
|
||||
8 | foo();
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function Component() {
|
||||
const foo = () => {
|
||||
// Cannot assign to globals
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function Component() {
|
||||
// Cannot assign to globals
|
||||
someUnknownGlobal = true;
|
||||
|
|
@ -14,13 +15,15 @@ function Component() {
|
|||
## Error
|
||||
|
||||
```
|
||||
1 | function Component() {
|
||||
2 | // Cannot assign to globals
|
||||
> 3 | someUnknownGlobal = true;
|
||||
| ^^^^^^^^^^^^^^^^^ InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (3:3)
|
||||
4 | moduleLocal = true;
|
||||
5 | }
|
||||
6 |
|
||||
2 | function Component() {
|
||||
3 | // Cannot assign to globals
|
||||
> 4 | someUnknownGlobal = true;
|
||||
| ^^^^^^^^^^^^^^^^^ InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (4:4)
|
||||
|
||||
InvalidReact: Unexpected reassignment of a variable which was defined outside of the component. Components and hooks should be pure and side-effect free, but variable reassignment is a form of side-effect. If this variable is used in rendering, use useState instead. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render) (5:5)
|
||||
5 | moduleLocal = true;
|
||||
6 | }
|
||||
7 |
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function Component() {
|
||||
// Cannot assign to globals
|
||||
someUnknownGlobal = true;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
function Component(props) {
|
||||
function hasErrors() {
|
||||
let hasErrors = false;
|
||||
|
|
@ -19,12 +20,12 @@ function Component(props) {
|
|||
## Error
|
||||
|
||||
```
|
||||
7 | return hasErrors;
|
||||
8 | }
|
||||
> 9 | return hasErrors();
|
||||
| ^^^^^^^^^ Invariant: [hoisting] Expected value for identifier to be initialized. hasErrors_0$15 (9:9)
|
||||
10 | }
|
||||
11 |
|
||||
8 | return hasErrors;
|
||||
9 | }
|
||||
> 10 | return hasErrors();
|
||||
| ^^^^^^^^^ Invariant: [InferMutationAliasingEffects] Expected value kind to be initialized. <unknown> hasErrors_0$15:TFunction (10:10)
|
||||
11 | }
|
||||
12 |
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
function Component(props) {
|
||||
function hasErrors() {
|
||||
let hasErrors = false;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import {useEffect} from 'react';
|
||||
import {print} from 'shared-runtime';
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import { useEffect } from "react";
|
||||
import { print } from "shared-runtime";
|
||||
|
||||
|
|
@ -48,9 +48,9 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Logs
|
||||
|
||||
```
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":139},"end":{"line":12,"column":1,"index":384},"filename":"mutate-after-useeffect-optional-chain.ts"},"detail":{"reason":"This mutates a variable that React considers immutable","description":null,"loc":{"start":{"line":10,"column":2,"index":345},"end":{"line":10,"column":5,"index":348},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"},"suggestions":null,"severity":"InvalidReact"}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":9,"column":2,"index":304},"end":{"line":9,"column":39,"index":341},"filename":"mutate-after-useeffect-optional-chain.ts"},"decorations":[{"start":{"line":9,"column":24,"index":326},"end":{"line":9,"column":27,"index":329},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":5,"column":0,"index":139},"end":{"line":12,"column":1,"index":384},"filename":"mutate-after-useeffect-optional-chain.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":171},"end":{"line":12,"column":1,"index":416},"filename":"mutate-after-useeffect-optional-chain.ts"},"detail":{"reason":"Updating a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the mutation before calling useEffect()","description":null,"severity":"InvalidReact","suggestions":null,"loc":{"start":{"line":10,"column":2,"index":377},"end":{"line":10,"column":5,"index":380},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":9,"column":2,"index":336},"end":{"line":9,"column":39,"index":373},"filename":"mutate-after-useeffect-optional-chain.ts"},"decorations":[{"start":{"line":9,"column":24,"index":358},"end":{"line":9,"column":27,"index":361},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":5,"column":0,"index":171},"end":{"line":12,"column":1,"index":416},"filename":"mutate-after-useeffect-optional-chain.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
```
|
||||
|
||||
### Eval output
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import {useEffect} from 'react';
|
||||
import {print} from 'shared-runtime';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
|
||||
import {useEffect, useRef} from 'react';
|
||||
import {print} from 'shared-runtime';
|
||||
|
|
@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { print } from "shared-runtime";
|
||||
|
|
@ -47,9 +47,9 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Logs
|
||||
|
||||
```
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":148},"end":{"line":11,"column":1,"index":311},"filename":"mutate-after-useeffect-ref-access.ts"},"detail":{"reason":"Mutating component props or hook arguments is not allowed. Consider using a local variable instead","description":null,"loc":{"start":{"line":9,"column":2,"index":269},"end":{"line":9,"column":16,"index":283},"filename":"mutate-after-useeffect-ref-access.ts"},"suggestions":null,"severity":"InvalidReact"}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":8,"column":2,"index":227},"end":{"line":8,"column":40,"index":265},"filename":"mutate-after-useeffect-ref-access.ts"},"decorations":[{"start":{"line":8,"column":24,"index":249},"end":{"line":8,"column":30,"index":255},"filename":"mutate-after-useeffect-ref-access.ts","identifierName":"arrRef"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":6,"column":0,"index":148},"end":{"line":11,"column":1,"index":311},"filename":"mutate-after-useeffect-ref-access.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":180},"end":{"line":11,"column":1,"index":343},"filename":"mutate-after-useeffect-ref-access.ts"},"detail":{"reason":"Mutating component props or hook arguments is not allowed. Consider using a local variable instead","description":null,"severity":"InvalidReact","suggestions":null,"loc":{"start":{"line":9,"column":2,"index":301},"end":{"line":9,"column":16,"index":315},"filename":"mutate-after-useeffect-ref-access.ts"}}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":8,"column":2,"index":259},"end":{"line":8,"column":40,"index":297},"filename":"mutate-after-useeffect-ref-access.ts"},"decorations":[{"start":{"line":8,"column":24,"index":281},"end":{"line":8,"column":30,"index":287},"filename":"mutate-after-useeffect-ref-access.ts","identifierName":"arrRef"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":6,"column":0,"index":180},"end":{"line":11,"column":1,"index":343},"filename":"mutate-after-useeffect-ref-access.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
```
|
||||
|
||||
### Eval output
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
|
||||
import {useEffect, useRef} from 'react';
|
||||
import {print} from 'shared-runtime';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import {useEffect} from 'react';
|
||||
|
||||
function Component({foo}) {
|
||||
|
|
@ -24,7 +24,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import { useEffect } from "react";
|
||||
|
||||
function Component(t0) {
|
||||
|
|
@ -47,9 +47,9 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Logs
|
||||
|
||||
```
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":4,"column":0,"index":101},"end":{"line":11,"column":1,"index":222},"filename":"mutate-after-useeffect.ts"},"detail":{"reason":"This mutates a variable that React considers immutable","description":null,"loc":{"start":{"line":9,"column":2,"index":194},"end":{"line":9,"column":5,"index":197},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},"suggestions":null,"severity":"InvalidReact"}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":6,"column":2,"index":149},"end":{"line":8,"column":4,"index":190},"filename":"mutate-after-useeffect.ts"},"decorations":[{"start":{"line":7,"column":4,"index":171},"end":{"line":7,"column":7,"index":174},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":4,"index":171},"end":{"line":7,"column":7,"index":174},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":13,"index":180},"end":{"line":7,"column":16,"index":183},"filename":"mutate-after-useeffect.ts","identifierName":"foo"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":4,"column":0,"index":101},"end":{"line":11,"column":1,"index":222},"filename":"mutate-after-useeffect.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":4,"column":0,"index":133},"end":{"line":11,"column":1,"index":254},"filename":"mutate-after-useeffect.ts"},"detail":{"reason":"Updating a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the mutation before calling useEffect()","description":null,"severity":"InvalidReact","suggestions":null,"loc":{"start":{"line":9,"column":2,"index":226},"end":{"line":9,"column":5,"index":229},"filename":"mutate-after-useeffect.ts","identifierName":"arr"}}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":6,"column":2,"index":181},"end":{"line":8,"column":4,"index":222},"filename":"mutate-after-useeffect.ts"},"decorations":[{"start":{"line":7,"column":4,"index":203},"end":{"line":7,"column":7,"index":206},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":4,"index":203},"end":{"line":7,"column":7,"index":206},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":13,"index":212},"end":{"line":7,"column":16,"index":215},"filename":"mutate-after-useeffect.ts","identifierName":"foo"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":4,"column":0,"index":133},"end":{"line":11,"column":1,"index":254},"filename":"mutate-after-useeffect.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
```
|
||||
|
||||
### Eval output
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import {useEffect} from 'react';
|
||||
|
||||
function Component({foo}) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {identity, mutate} from 'shared-runtime';
|
||||
|
||||
function Component(props) {
|
||||
|
|
@ -23,38 +24,22 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import { identity, mutate } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const $ = _c(5);
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = {};
|
||||
$[0] = t0;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
}
|
||||
const key = t0;
|
||||
let t1;
|
||||
if ($[1] !== props.value) {
|
||||
t1 = identity([props.value]);
|
||||
$[1] = props.value;
|
||||
$[2] = t1;
|
||||
} else {
|
||||
t1 = $[2];
|
||||
}
|
||||
let t2;
|
||||
if ($[3] !== t1) {
|
||||
t2 = { [key]: t1 };
|
||||
$[3] = t1;
|
||||
$[4] = t2;
|
||||
} else {
|
||||
t2 = $[4];
|
||||
}
|
||||
const context = t2;
|
||||
const $ = _c(2);
|
||||
let context;
|
||||
if ($[0] !== props.value) {
|
||||
const key = {};
|
||||
context = { [key]: identity([props.value]) };
|
||||
|
||||
mutate(key);
|
||||
mutate(key);
|
||||
$[0] = props.value;
|
||||
$[1] = context;
|
||||
} else {
|
||||
context = $[1];
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {identity, mutate} from 'shared-runtime';
|
||||
|
||||
function Component(props) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {identity, mutate, mutateAndReturn} from 'shared-runtime';
|
||||
|
||||
function Component(props) {
|
||||
|
|
@ -23,15 +24,26 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import { identity, mutate, mutateAndReturn } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const $ = _c(2);
|
||||
const $ = _c(4);
|
||||
let context;
|
||||
if ($[0] !== props.value) {
|
||||
const key = { a: "key" };
|
||||
context = { [key.a]: identity([props.value]) };
|
||||
|
||||
const t0 = key.a;
|
||||
const t1 = identity([props.value]);
|
||||
let t2;
|
||||
if ($[2] !== t1) {
|
||||
t2 = { [t0]: t1 };
|
||||
$[2] = t1;
|
||||
$[3] = t2;
|
||||
} else {
|
||||
t2 = $[3];
|
||||
}
|
||||
context = t2;
|
||||
|
||||
mutate(key);
|
||||
$[0] = props.value;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {identity, mutate, mutateAndReturn} from 'shared-runtime';
|
||||
|
||||
function Component(props) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies
|
||||
// @inferEffectDependencies @enableNewMutationAliasingModel
|
||||
import {useEffect, useState} from 'react';
|
||||
import {print} from 'shared-runtime';
|
||||
|
||||
|
|
@ -26,7 +26,7 @@ function ReactiveRefInEffect(props) {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime"; // @inferEffectDependencies
|
||||
import { c as _c } from "react/compiler-runtime"; // @inferEffectDependencies @enableNewMutationAliasingModel
|
||||
import { useEffect, useState } from "react";
|
||||
import { print } from "shared-runtime";
|
||||
|
||||
|
|
@ -34,22 +34,28 @@ import { print } from "shared-runtime";
|
|||
* setState types are not enough to determine to omit from deps. Must also take reactivity into account.
|
||||
*/
|
||||
function ReactiveRefInEffect(props) {
|
||||
const $ = _c(2);
|
||||
const $ = _c(4);
|
||||
const [, setState1] = useRef("initial value");
|
||||
const [, setState2] = useRef("initial value");
|
||||
let setState;
|
||||
if (props.foo) {
|
||||
setState = setState1;
|
||||
if ($[0] !== props.foo) {
|
||||
if (props.foo) {
|
||||
setState = setState1;
|
||||
} else {
|
||||
setState = setState2;
|
||||
}
|
||||
$[0] = props.foo;
|
||||
$[1] = setState;
|
||||
} else {
|
||||
setState = setState2;
|
||||
setState = $[1];
|
||||
}
|
||||
let t0;
|
||||
if ($[0] !== setState) {
|
||||
if ($[2] !== setState) {
|
||||
t0 = () => print(setState);
|
||||
$[0] = setState;
|
||||
$[1] = t0;
|
||||
$[2] = setState;
|
||||
$[3] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
t0 = $[3];
|
||||
}
|
||||
useEffect(t0, [setState]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @inferEffectDependencies
|
||||
// @inferEffectDependencies @enableNewMutationAliasingModel
|
||||
import {useEffect, useState} from 'react';
|
||||
import {print} from 'shared-runtime';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @noEmit @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @noEmit @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import {print} from 'shared-runtime';
|
||||
import useEffectWrapper from 'useEffectWrapper';
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
// @inferEffectDependencies @noEmit @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @noEmit @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import { print } from "shared-runtime";
|
||||
import useEffectWrapper from "useEffectWrapper";
|
||||
|
||||
|
|
@ -52,10 +52,10 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Logs
|
||||
|
||||
```
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":163},"end":{"line":13,"column":1,"index":357},"filename":"retry-no-emit.ts"},"detail":{"reason":"This mutates a variable that React considers immutable","description":null,"loc":{"start":{"line":11,"column":2,"index":320},"end":{"line":11,"column":6,"index":324},"filename":"retry-no-emit.ts","identifierName":"arr2"},"suggestions":null,"severity":"InvalidReact"}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":7,"column":2,"index":216},"end":{"line":7,"column":36,"index":250},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":7,"column":31,"index":245},"end":{"line":7,"column":34,"index":248},"filename":"retry-no-emit.ts","identifierName":"arr"}]}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":10,"column":2,"index":274},"end":{"line":10,"column":44,"index":316},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":10,"column":25,"index":297},"end":{"line":10,"column":29,"index":301},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":10,"column":25,"index":297},"end":{"line":10,"column":29,"index":301},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":10,"column":35,"index":307},"end":{"line":10,"column":42,"index":314},"filename":"retry-no-emit.ts","identifierName":"propVal"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":5,"column":0,"index":163},"end":{"line":13,"column":1,"index":357},"filename":"retry-no-emit.ts"},"fnName":"Foo","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":195},"end":{"line":13,"column":1,"index":389},"filename":"retry-no-emit.ts"},"detail":{"reason":"This mutates a variable that React considers immutable","description":null,"severity":"InvalidReact","suggestions":null,"loc":{"start":{"line":11,"column":2,"index":352},"end":{"line":11,"column":6,"index":356},"filename":"retry-no-emit.ts","identifierName":"arr2"}}}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":7,"column":2,"index":248},"end":{"line":7,"column":36,"index":282},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":7,"column":31,"index":277},"end":{"line":7,"column":34,"index":280},"filename":"retry-no-emit.ts","identifierName":"arr"}]}
|
||||
{"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":10,"column":2,"index":306},"end":{"line":10,"column":44,"index":348},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":10,"column":25,"index":329},"end":{"line":10,"column":29,"index":333},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":10,"column":25,"index":329},"end":{"line":10,"column":29,"index":333},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":10,"column":35,"index":339},"end":{"line":10,"column":42,"index":346},"filename":"retry-no-emit.ts","identifierName":"propVal"}]}
|
||||
{"kind":"CompileSuccess","fnLoc":{"start":{"line":5,"column":0,"index":195},"end":{"line":13,"column":1,"index":389},"filename":"retry-no-emit.ts"},"fnName":"Foo","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
|
||||
```
|
||||
|
||||
### Eval output
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @inferEffectDependencies @noEmit @panicThreshold:"none" @loggerTestOnly
|
||||
// @inferEffectDependencies @noEmit @panicThreshold:"none" @loggerTestOnly @enableNewMutationAliasingModel
|
||||
import {print} from 'shared-runtime';
|
||||
import useEffectWrapper from 'useEffectWrapper';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableFire
|
||||
// @enableFire @enableNewMutationAliasingModel
|
||||
import {fire} from 'react';
|
||||
|
||||
function Component({bar, baz}) {
|
||||
|
|
@ -26,51 +26,64 @@ function Component({bar, baz}) {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c, useFire } from "react/compiler-runtime"; // @enableFire
|
||||
import { c as _c, useFire } from "react/compiler-runtime"; // @enableFire @enableNewMutationAliasingModel
|
||||
import { fire } from "react";
|
||||
|
||||
function Component(t0) {
|
||||
const $ = _c(9);
|
||||
const { bar, baz } = t0;
|
||||
let t1;
|
||||
if ($[0] !== bar) {
|
||||
t1 = () => {
|
||||
console.log(bar);
|
||||
};
|
||||
$[0] = bar;
|
||||
$[1] = t1;
|
||||
const $ = _c(13);
|
||||
let bar;
|
||||
let baz;
|
||||
let foo;
|
||||
if ($[0] !== t0) {
|
||||
({ bar, baz } = t0);
|
||||
let t1;
|
||||
if ($[4] !== bar) {
|
||||
t1 = () => {
|
||||
console.log(bar);
|
||||
};
|
||||
$[4] = bar;
|
||||
$[5] = t1;
|
||||
} else {
|
||||
t1 = $[5];
|
||||
}
|
||||
foo = t1;
|
||||
$[0] = t0;
|
||||
$[1] = bar;
|
||||
$[2] = baz;
|
||||
$[3] = foo;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
bar = $[1];
|
||||
baz = $[2];
|
||||
foo = $[3];
|
||||
}
|
||||
const foo = t1;
|
||||
const t2 = useFire(foo);
|
||||
const t3 = useFire(baz);
|
||||
let t4;
|
||||
if ($[2] !== bar || $[3] !== t2 || $[4] !== t3) {
|
||||
t4 = () => {
|
||||
t2(bar);
|
||||
t3(bar);
|
||||
};
|
||||
$[2] = bar;
|
||||
$[3] = t2;
|
||||
$[4] = t3;
|
||||
$[5] = t4;
|
||||
} else {
|
||||
t4 = $[5];
|
||||
}
|
||||
useEffect(t4);
|
||||
let t5;
|
||||
if ($[6] !== bar || $[7] !== t2) {
|
||||
t5 = () => {
|
||||
const t1 = useFire(foo);
|
||||
const t2 = useFire(baz);
|
||||
let t3;
|
||||
if ($[6] !== bar || $[7] !== t1 || $[8] !== t2) {
|
||||
t3 = () => {
|
||||
t1(bar);
|
||||
t2(bar);
|
||||
};
|
||||
$[6] = bar;
|
||||
$[7] = t2;
|
||||
$[8] = t5;
|
||||
$[7] = t1;
|
||||
$[8] = t2;
|
||||
$[9] = t3;
|
||||
} else {
|
||||
t5 = $[8];
|
||||
t3 = $[9];
|
||||
}
|
||||
useEffect(t5);
|
||||
useEffect(t3);
|
||||
let t4;
|
||||
if ($[10] !== bar || $[11] !== t1) {
|
||||
t4 = () => {
|
||||
t1(bar);
|
||||
};
|
||||
$[10] = bar;
|
||||
$[11] = t1;
|
||||
$[12] = t4;
|
||||
} else {
|
||||
t4 = $[12];
|
||||
}
|
||||
useEffect(t4);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @enableFire
|
||||
// @enableFire @enableNewMutationAliasingModel
|
||||
import {fire} from 'react';
|
||||
|
||||
function Component({bar, baz}) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {useCallback} from 'react';
|
||||
import {Stringify} from 'shared-runtime';
|
||||
|
||||
|
|
@ -35,44 +36,51 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import { useCallback } from "react";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
function Foo(t0) {
|
||||
const $ = _c(8);
|
||||
const $ = _c(10);
|
||||
const { arr1, arr2, foo } = t0;
|
||||
let getVal1;
|
||||
let t1;
|
||||
if ($[0] !== arr1 || $[1] !== arr2 || $[2] !== foo) {
|
||||
const x = [arr1];
|
||||
|
||||
if ($[0] !== arr1) {
|
||||
t1 = [arr1];
|
||||
$[0] = arr1;
|
||||
$[1] = t1;
|
||||
} else {
|
||||
t1 = $[1];
|
||||
}
|
||||
const x = t1;
|
||||
let getVal1;
|
||||
let t2;
|
||||
if ($[2] !== arr2 || $[3] !== foo || $[4] !== x) {
|
||||
let y = [];
|
||||
|
||||
getVal1 = _temp;
|
||||
|
||||
t1 = () => [y];
|
||||
t2 = () => [y];
|
||||
foo ? (y = x.concat(arr2)) : y;
|
||||
$[0] = arr1;
|
||||
$[1] = arr2;
|
||||
$[2] = foo;
|
||||
$[3] = getVal1;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
getVal1 = $[3];
|
||||
t1 = $[4];
|
||||
}
|
||||
const getVal2 = t1;
|
||||
let t2;
|
||||
if ($[5] !== getVal1 || $[6] !== getVal2) {
|
||||
t2 = <Stringify val1={getVal1} val2={getVal2} shouldInvokeFns={true} />;
|
||||
$[2] = arr2;
|
||||
$[3] = foo;
|
||||
$[4] = x;
|
||||
$[5] = getVal1;
|
||||
$[6] = getVal2;
|
||||
$[7] = t2;
|
||||
$[6] = t2;
|
||||
} else {
|
||||
t2 = $[7];
|
||||
getVal1 = $[5];
|
||||
t2 = $[6];
|
||||
}
|
||||
return t2;
|
||||
const getVal2 = t2;
|
||||
let t3;
|
||||
if ($[7] !== getVal1 || $[8] !== getVal2) {
|
||||
t3 = <Stringify val1={getVal1} val2={getVal2} shouldInvokeFns={true} />;
|
||||
$[7] = getVal1;
|
||||
$[8] = getVal2;
|
||||
$[9] = t3;
|
||||
} else {
|
||||
t3 = $[9];
|
||||
}
|
||||
return t3;
|
||||
}
|
||||
function _temp() {
|
||||
return { x: 2 };
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {useCallback} from 'react';
|
||||
import {Stringify} from 'shared-runtime';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {useCallback} from 'react';
|
||||
import {Stringify} from 'shared-runtime';
|
||||
|
||||
|
|
@ -30,37 +31,44 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import { useCallback } from "react";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
// We currently produce invalid output (incorrect scoping for `y` declaration)
|
||||
function useFoo(arr1, arr2) {
|
||||
const $ = _c(5);
|
||||
const $ = _c(7);
|
||||
let t0;
|
||||
if ($[0] !== arr1 || $[1] !== arr2) {
|
||||
const x = [arr1];
|
||||
|
||||
if ($[0] !== arr1) {
|
||||
t0 = [arr1];
|
||||
$[0] = arr1;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const x = t0;
|
||||
let t1;
|
||||
if ($[2] !== arr2 || $[3] !== x) {
|
||||
let y;
|
||||
t0 = () => ({ y });
|
||||
t1 = () => ({ y });
|
||||
|
||||
(y = x.concat(arr2)), y;
|
||||
$[0] = arr1;
|
||||
$[1] = arr2;
|
||||
$[2] = t0;
|
||||
} else {
|
||||
t0 = $[2];
|
||||
}
|
||||
const getVal = t0;
|
||||
let t1;
|
||||
if ($[3] !== getVal) {
|
||||
t1 = <Stringify getVal={getVal} shouldInvokeFns={true} />;
|
||||
$[3] = getVal;
|
||||
$[2] = arr2;
|
||||
$[3] = x;
|
||||
$[4] = t1;
|
||||
} else {
|
||||
t1 = $[4];
|
||||
}
|
||||
return t1;
|
||||
const getVal = t1;
|
||||
let t2;
|
||||
if ($[5] !== getVal) {
|
||||
t2 = <Stringify getVal={getVal} shouldInvokeFns={true} />;
|
||||
$[5] = getVal;
|
||||
$[6] = t2;
|
||||
} else {
|
||||
t2 = $[6];
|
||||
}
|
||||
return t2;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {useCallback} from 'react';
|
||||
import {Stringify} from 'shared-runtime';
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
## Input
|
||||
|
||||
```javascript
|
||||
// @enableNewMutationAliasingModel
|
||||
import {useMemo} from 'react';
|
||||
|
||||
function useFoo(arr1, arr2) {
|
||||
|
|
@ -26,33 +27,40 @@ export const FIXTURE_ENTRYPOINT = {
|
|||
## Code
|
||||
|
||||
```javascript
|
||||
import { c as _c } from "react/compiler-runtime";
|
||||
import { c as _c } from "react/compiler-runtime"; // @enableNewMutationAliasingModel
|
||||
import { useMemo } from "react";
|
||||
|
||||
function useFoo(arr1, arr2) {
|
||||
const $ = _c(5);
|
||||
let y;
|
||||
if ($[0] !== arr1 || $[1] !== arr2) {
|
||||
const x = [arr1];
|
||||
|
||||
(y = x.concat(arr2)), y;
|
||||
$[0] = arr1;
|
||||
$[1] = arr2;
|
||||
$[2] = y;
|
||||
} else {
|
||||
y = $[2];
|
||||
}
|
||||
const $ = _c(7);
|
||||
let t0;
|
||||
let t1;
|
||||
if ($[3] !== y) {
|
||||
t1 = { y };
|
||||
$[3] = y;
|
||||
$[4] = t1;
|
||||
if ($[0] !== arr1) {
|
||||
t0 = [arr1];
|
||||
$[0] = arr1;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t1 = $[4];
|
||||
t0 = $[1];
|
||||
}
|
||||
t0 = t1;
|
||||
return t0;
|
||||
const x = t0;
|
||||
let y;
|
||||
if ($[2] !== arr2 || $[3] !== x) {
|
||||
(y = x.concat(arr2)), y;
|
||||
$[2] = arr2;
|
||||
$[3] = x;
|
||||
$[4] = y;
|
||||
} else {
|
||||
y = $[4];
|
||||
}
|
||||
let t1;
|
||||
let t2;
|
||||
if ($[5] !== y) {
|
||||
t2 = { y };
|
||||
$[5] = y;
|
||||
$[6] = t2;
|
||||
} else {
|
||||
t2 = $[6];
|
||||
}
|
||||
t1 = t2;
|
||||
return t1;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// @enableNewMutationAliasingModel
|
||||
import {useMemo} from 'react';
|
||||
|
||||
function useFoo(arr1, arr2) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user