@samitouri / QOS-React-1 / commits / a39da6c61f

[compiler] Use new diagnostics for core inference errors (#33760)

Uses the new diagnostic type for errors created during mutation/aliasing inference, such as errors for mutating immutable values like props or state, reassigning globals, etc. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33760). * #33981 * #33777 * #33767 * #33765 * __->__ #33760

Joseph Savona committed Jul 24, 2025 at 15:43 UTC a39da6c61feb5d10c988ddb55b7451a5af165783
61 files changed +312 -349
compiler/packages/babel-plugin-react-compiler/src/HIR/PrintHIR.ts
+3 -3
@@ -995,13 +995,13 @@ export function printAliasingEffect(effect: AliasingEffect): string {
995 return `${effect.kind} ${printPlaceForAliasEffect(effect.value)}`;
996 }
997 case 'MutateFrozen': {
998 - return `MutateFrozen ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
998 + return `MutateFrozen ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.category)}`;
999 }
1000 case 'MutateGlobal': {
1001 - return `MutateGlobal ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
1001 + return `MutateGlobal ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.category)}`;
1002 }
1003 case 'Impure': {
1004 - return `Impure ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.reason)}`;
1004 + return `Impure ${printPlaceForAliasEffect(effect.place)} reason=${JSON.stringify(effect.error.category)}`;
1005 }
1006 case 'Render': {
1007 return `Render ${printPlaceForAliasEffect(effect.place)}`;
compiler/packages/babel-plugin-react-compiler/src/Inference/AliasingEffects.ts
+6 -6
@@ -5,7 +5,7 @@
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 -import {CompilerErrorDetailOptions} from '../CompilerError';
8 +import {CompilerDiagnostic} from '../CompilerError';
9 import {
10 FunctionExpression,
11 GeneratedSource,
@@ -133,19 +133,19 @@ export type AliasingEffect =
133 /**
134 * Mutation of a value known to be immutable
135 */
136 - | {kind: 'MutateFrozen'; place: Place; error: CompilerErrorDetailOptions}
136 + | {kind: 'MutateFrozen'; place: Place; error: CompilerDiagnostic}
137 /**
138 * Mutation of a global
139 */
140 | {
141 kind: 'MutateGlobal';
142 place: Place;
143 - error: CompilerErrorDetailOptions;
143 + error: CompilerDiagnostic;
144 }
145 /**
146 * Indicates a side-effect that is not safe during render
147 */
148 - | {kind: 'Impure'; place: Place; error: CompilerErrorDetailOptions}
148 + | {kind: 'Impure'; place: Place; error: CompilerDiagnostic}
149 /**
150 * Indicates that a given place is accessed during render. Used to distingush
151 * hook arguments that are known to be called immediately vs those used for
@@ -211,9 +211,9 @@ export function hashEffect(effect: AliasingEffect): string {
211 effect.kind,
212 effect.place.identifier.id,
213 effect.error.severity,
214 - effect.error.reason,
214 + effect.error.category,
215 effect.error.description,
216 - printSourceLocation(effect.error.loc ?? GeneratedSource),
216 + printSourceLocation(effect.error.primaryLocation() ?? GeneratedSource),
217 ].join(':');
218 }
219 case 'Mutate':
compiler/packages/babel-plugin-react-compiler/src/Inference/InferFunctionEffects.ts
+11 -11
@@ -326,26 +326,26 @@ function isEffectSafeOutsideRender(effect: FunctionEffect): boolean {
326
327 export function getWriteErrorReason(abstractValue: AbstractValue): string {
328 if (abstractValue.reason.has(ValueReason.Global)) {
329 - return 'Writing to a variable defined outside a component or hook is not allowed. Consider using an effect';
329 + return 'Modifying a variable defined outside a component or hook is not allowed. Consider using an effect';
330 } else if (abstractValue.reason.has(ValueReason.JsxCaptured)) {
331 - return 'Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX';
331 + return 'Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX';
332 } else if (abstractValue.reason.has(ValueReason.Context)) {
333 - return `Mutating a value returned from 'useContext()', which should not be mutated`;
333 + return `Modifying a value returned from 'useContext()' is not allowed.`;
334 } else if (abstractValue.reason.has(ValueReason.KnownReturnSignature)) {
335 - return 'Mutating a value returned from a function whose return value should not be mutated';
335 + return 'Modifying a value returned from a function whose return value should not be mutated';
336 } else if (abstractValue.reason.has(ValueReason.ReactiveFunctionArgument)) {
337 - return 'Mutating component props or hook arguments is not allowed. Consider using a local variable instead';
337 + return 'Modifying component props or hook arguments is not allowed. Consider using a local variable instead';
338 } else if (abstractValue.reason.has(ValueReason.State)) {
339 - return "Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead";
339 + return "Modifying a value returned from 'useState()', which should not be modified directly. Use the setter function to update instead";
340 } else if (abstractValue.reason.has(ValueReason.ReducerState)) {
341 - return "Mutating a value returned from 'useReducer()', which should not be mutated. Use the dispatch function to update instead";
341 + return "Modifying a value returned from 'useReducer()', which should not be modified directly. Use the dispatch function to update instead";
342 } else if (abstractValue.reason.has(ValueReason.Effect)) {
343 - return 'Updating a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the mutation before calling useEffect()';
343 + return 'Modifying a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the modification before calling useEffect()';
344 } else if (abstractValue.reason.has(ValueReason.HookCaptured)) {
345 - return 'Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook';
345 + return 'Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook';
346 } else if (abstractValue.reason.has(ValueReason.HookReturn)) {
347 - return 'Updating a value returned from a hook is not allowed. Consider moving the mutation into the hook where the value is constructed';
347 + return 'Modifying a value returned from a hook is not allowed. Consider moving the modification into the hook where the value is constructed';
348 } else {
349 - return 'This mutates a variable that React considers immutable';
349 + return 'This modifies a variable that React considers immutable';
350 }
351 }
compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingEffects.ts
+65 -58
@@ -6,6 +6,7 @@
6 */
7
8 import {
9 + CompilerDiagnostic,
10 CompilerError,
11 Effect,
12 ErrorSeverity,
@@ -446,20 +447,24 @@ function applySignature(
447 reason: value.reason,
448 context: new Set(),
449 });
450 + const message =
451 + effect.value.identifier.name !== null &&
452 + effect.value.identifier.name.kind === 'named'
453 + ? `\`${effect.value.identifier.name.value}\` cannot be modified`
454 + : 'This value cannot be modified';
455 effects.push({
456 kind: 'MutateFrozen',
457 place: effect.value,
452 - error: {
458 + error: CompilerDiagnostic.create({
459 severity: ErrorSeverity.InvalidReact,
454 - reason,
455 - description:
456 - effect.value.identifier.name !== null &&
457 - effect.value.identifier.name.kind === 'named'
458 - ? `Found mutation of \`${effect.value.identifier.name.value}\``
459 - : null,
460 - loc: effect.value.loc,
460 + category: 'This value cannot be modified',
461 + description: reason,
462 suggestions: null,
462 - },
463 + }).withDetail({
464 + kind: 'error',
465 + loc: effect.value.loc,
466 + message,
467 + }),
468 });
469 }
470 }
@@ -1016,30 +1021,28 @@ function applyEffect(
1021 const description =
1022 effect.value.identifier.name !== null &&
1023 effect.value.identifier.name.kind === 'named'
1019 - ? `Variable \`${effect.value.identifier.name.value}\` is accessed before it is declared`
1020 - : null;
1024 + ? `Variable \`${effect.value.identifier.name.value}\``
1025 + : 'This variable';
1026 const hoistedAccess = context.hoistedContextDeclarations.get(
1027 effect.value.identifier.declarationId,
1028 );
1029 + const diagnostic = CompilerDiagnostic.create({
1030 + severity: ErrorSeverity.InvalidReact,
1031 + category: 'Cannot access variable before it is declared',
1032 + description: `${description} is accessed before it is declared, which prevents the earlier access from updating when this value changes over time`,
1033 + });
1034 if (hoistedAccess != null && hoistedAccess.loc != effect.value.loc) {
1025 - applyEffect(
1026 - context,
1027 - state,
1028 - {
1029 - kind: 'MutateFrozen',
1030 - place: effect.value,
1031 - error: {
1032 - severity: ErrorSeverity.InvalidReact,
1033 - reason: `This variable is accessed before it is declared, which may prevent it from updating as the assigned value changes over time`,
1034 - description,
1035 - loc: hoistedAccess.loc,
1036 - suggestions: null,
1037 - },
1038 - },
1039 - initialized,
1040 - effects,
1041 - );
1035 + diagnostic.withDetail({
1036 + kind: 'error',
1037 + loc: hoistedAccess.loc,
1038 + message: 'Variable accessed before it is declared',
1039 + });
1040 }
1041 + diagnostic.withDetail({
1042 + kind: 'error',
1043 + loc: effect.value.loc,
1044 + message: 'The variable is declared here',
1045 + });
1046
1047 applyEffect(
1048 context,
@@ -1047,13 +1050,7 @@ function applyEffect(
1050 {
1051 kind: 'MutateFrozen',
1052 place: effect.value,
1050 - error: {
1051 - severity: ErrorSeverity.InvalidReact,
1052 - reason: `This variable is accessed before it is declared, which prevents the earlier access from updating when this value changes over time`,
1053 - description,
1054 - loc: effect.value.loc,
1055 - suggestions: null,
1056 - },
1053 + error: diagnostic,
1054 },
1055 initialized,
1056 effects,
@@ -1064,11 +1061,11 @@ function applyEffect(
1061 reason: value.reason,
1062 context: new Set(),
1063 });
1067 - const description =
1064 + const message =
1065 effect.value.identifier.name !== null &&
1066 effect.value.identifier.name.kind === 'named'
1070 - ? `Found mutation of \`${effect.value.identifier.name.value}\``
1071 - : null;
1067 + ? `\`${effect.value.identifier.name.value}\` cannot be modified`
1068 + : 'This value cannot be modified';
1069 applyEffect(
1070 context,
1071 state,
@@ -1078,13 +1075,15 @@ function applyEffect(
1075 ? 'MutateFrozen'
1076 : 'MutateGlobal',
1077 place: effect.value,
1081 - error: {
1078 + error: CompilerDiagnostic.create({
1079 severity: ErrorSeverity.InvalidReact,
1083 - reason,
1084 - description,
1080 + category: 'This value cannot be modified',
1081 + description: reason,
1082 + }).withDetail({
1083 + kind: 'error',
1084 loc: effect.value.loc,
1086 - suggestions: null,
1087 - },
1085 + message,
1086 + }),
1087 },
1088 initialized,
1089 effects,
@@ -2006,13 +2005,18 @@ function computeSignatureForInstruction(
2005 effects.push({
2006 kind: 'MutateGlobal',
2007 place: value.value,
2009 - error: {
2010 - reason:
2011 - '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)',
2012 - loc: instr.loc,
2013 - suggestions: null,
2008 + error: CompilerDiagnostic.create({
2009 severity: ErrorSeverity.InvalidReact,
2015 - },
2010 + category:
2011 + 'Cannot reassign variables declared outside of the component/hook',
2012 + description:
2013 + 'Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)',
2014 + suggestions: null,
2015 + }).withDetail({
2016 + kind: 'error',
2017 + loc: instr.loc,
2018 + message: 'Cannot reassign variable',
2019 + }),
2020 });
2021 effects.push({kind: 'Assign', from: value.value, into: lvalue});
2022 break;
@@ -2102,17 +2106,20 @@ function computeEffectsForLegacySignature(
2106 effects.push({
2107 kind: 'Impure',
2108 place: receiver,
2105 - error: {
2106 - reason:
2107 - '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)',
2108 - description:
2109 - signature.canonicalName != null
2110 - ? `\`${signature.canonicalName}\` is an impure function whose results may change on every call`
2111 - : null,
2109 + error: CompilerDiagnostic.create({
2110 severity: ErrorSeverity.InvalidReact,
2113 - loc,
2111 + category: 'Cannot call impure function during render',
2112 + description:
2113 + (signature.canonicalName != null
2114 + ? `\`${signature.canonicalName}\` is an impure function. `
2115 + : '') +
2116 + 'Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)',
2117 suggestions: null,
2115 - },
2118 + }).withDetail({
2119 + kind: 'error',
2120 + loc,
2121 + message: 'Cannot call impure function',
2122 + }),
2123 });
2124 }
2125 const stores: Array<Place> = [];
compiler/packages/babel-plugin-react-compiler/src/Inference/InferMutationAliasingRanges.ts
+2 -2
@@ -195,7 +195,7 @@ export function inferMutationAliasingRanges(
195 effect.kind === 'MutateGlobal' ||
196 effect.kind === 'Impure'
197 ) {
198 - errors.push(effect.error);
198 + errors.pushDiagnostic(effect.error);
199 functionEffects.push(effect);
200 } else if (effect.kind === 'Render') {
201 renders.push({index: index++, place: effect.place});
@@ -549,7 +549,7 @@ function appendFunctionErrors(errors: CompilerError, fn: HIRFunction): void {
549 case 'Impure':
550 case 'MutateFrozen':
551 case 'MutateGlobal': {
552 - errors.push(effect.error);
552 + errors.pushDiagnostic(effect.error);
553 break;
554 }
555 }
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.assign-global-in-component-tag-function.expect.md
+4 -4
@@ -16,18 +16,18 @@ function Component() {
16
17 ```
18 Found 1 error:
19 -Error: 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)
19 +Error: Cannot reassign variables declared outside of the component/hook
20 +
21 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
22
23 error.assign-global-in-component-tag-function.ts:3:4
24 1 | function Component() {
25 2 | const Foo = () => {
26 > 3 | someGlobal = true;
25 - | ^^^^^^^^^^ 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)
27 + | ^^^^^^^^^^ Cannot reassign variable
28 4 | };
29 5 | return <Foo />;
30 6 | }
29 -
30 -
31 ```
32
33
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.assign-global-in-jsx-children.expect.md
+4 -4
@@ -19,18 +19,18 @@ function Component() {
19
20 ```
21 Found 1 error:
22 -Error: 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)
22 +Error: Cannot reassign variables declared outside of the component/hook
23 +
24 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
25
26 error.assign-global-in-jsx-children.ts:3:4
27 1 | function Component() {
28 2 | const foo = () => {
29 > 3 | someGlobal = true;
28 - | ^^^^^^^^^^ 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)
30 + | ^^^^^^^^^^ Cannot reassign variable
31 4 | };
32 5 | // Children are generally access/called during render, so
33 6 | // modifying a global in a children function is almost
32 -
33 -
34 ```
35
36
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.hook-call-freezes-captured-identifier.expect.md
+4 -4
@@ -30,18 +30,18 @@ export const FIXTURE_ENTRYPOINT = {
30
31 ```
32 Found 1 error:
33 -Error: Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook
33 +Error: This value cannot be modified
34 +
35 +Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook
36
37 error.hook-call-freezes-captured-identifier.ts:13:2
38 11 | });
39 12 |
40 > 13 | x.value += count;
39 - | ^ Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook
41 + | ^ This value cannot be modified
42 14 | return <Stringify x={x} cb={cb} />;
43 15 | }
44 16 |
43 -
44 -
45 ```
46
47
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.hook-call-freezes-captured-memberexpr.expect.md
+4 -4
@@ -30,18 +30,18 @@ export const FIXTURE_ENTRYPOINT = {
30
31 ```
32 Found 1 error:
33 -Error: Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook
33 +Error: This value cannot be modified
34 +
35 +Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook
36
37 error.hook-call-freezes-captured-memberexpr.ts:13:2
38 11 | });
39 12 |
40 > 13 | x.value += count;
39 - | ^ Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook
41 + | ^ This value cannot be modified
42 14 | return <Stringify x={x} cb={cb} />;
43 15 | }
44 16 |
43 -
44 -
45 ```
46
47
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-array-push-frozen.expect.md
+4 -4
@@ -16,18 +16,18 @@ function Component(props) {
16
17 ```
18 Found 1 error:
19 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
19 +Error: This value cannot be modified
20 +
21 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
22
23 error.invalid-array-push-frozen.ts:4:2
24 2 | const x = [];
25 3 | <div>{x}</div>;
26 > 4 | x.push(props.value);
25 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
27 + | ^ This value cannot be modified
28 5 | return x;
29 6 | }
30 7 |
29 -
30 -
31 ```
32
33
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-computed-store-to-frozen-value.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Component(props) {
17
18 ```
19 Found 1 error:
20 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
20 +Error: This value cannot be modified
21 +
22 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
23
24 error.invalid-computed-store-to-frozen-value.ts:5:2
25 3 | // freeze
26 4 | <div>{x}</div>;
27 > 5 | x[0] = true;
26 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
28 + | ^ This value cannot be modified
29 6 | return x;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-delete-computed-property-of-frozen-value.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Component(props) {
17
18 ```
19 Found 1 error:
20 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
20 +Error: This value cannot be modified
21 +
22 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
23
24 error.invalid-delete-computed-property-of-frozen-value.ts:5:9
25 3 | // freeze
26 4 | <div>{x}</div>;
27 > 5 | delete x[y];
26 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
28 + | ^ This value cannot be modified
29 6 | return x;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-delete-property-of-frozen-value.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Component(props) {
17
18 ```
19 Found 1 error:
20 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
20 +Error: This value cannot be modified
21 +
22 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
23
24 error.invalid-delete-property-of-frozen-value.ts:5:9
25 3 | // freeze
26 4 | <div>{x}</div>;
27 > 5 | delete x.y;
26 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
28 + | ^ This value cannot be modified
29 6 | return x;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-destructure-assignment-to-global.expect.md
+4 -4
@@ -14,17 +14,17 @@ function useFoo(props) {
14
15 ```
16 Found 1 error:
17 -Error: 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)
17 +Error: Cannot reassign variables declared outside of the component/hook
18 +
19 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
20
21 error.invalid-destructure-assignment-to-global.ts:2:3
22 1 | function useFoo(props) {
23 > 2 | [x] = props;
22 - | ^ 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)
24 + | ^ Cannot reassign variable
25 3 | return {x};
26 4 | }
27 5 |
26 -
27 -
28 ```
29
30
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-destructure-to-local-global-variables.expect.md
+4 -4
@@ -16,18 +16,18 @@ function Component(props) {
16
17 ```
18 Found 1 error:
19 -Error: 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)
19 +Error: Cannot reassign variables declared outside of the component/hook
20 +
21 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
22
23 error.invalid-destructure-to-local-global-variables.ts:3:6
24 1 | function Component(props) {
25 2 | let a;
26 > 3 | [a, b] = props.value;
25 - | ^ 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)
27 + | ^ Cannot reassign variable
28 4 |
29 5 | return [a, b];
30 6 | }
29 -
30 -
31 ```
32
33
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-function-expression-mutates-immutable-value.expect.md
+3 -5
@@ -19,20 +19,18 @@ function Component(props) {
19
20 ```
21 Found 1 error:
22 -Error: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead
22 +Error: This value cannot be modified
23
24 -Found mutation of `x`.
24 +Modifying a value returned from 'useState()', which should not be modified directly. Use the setter function to update instead
25
26 error.invalid-function-expression-mutates-immutable-value.ts:5:4
27 3 | const onChange = e => {
28 4 | // INVALID! should use copy-on-write and pass the new value
29 > 5 | x.value = e.target.value;
30 - | ^ Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead
30 + | ^ `x` cannot be modified
31 6 | setX(x);
32 7 | };
33 8 | return <input value={x.value} onChange={onChange} />;
34 -
35 -
34 ```
35
36
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-global-reassignment-indirect.expect.md
+4 -4
@@ -36,18 +36,18 @@ export const FIXTURE_ENTRYPOINT = {
36
37 ```
38 Found 1 error:
39 -Error: 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)
39 +Error: Cannot reassign variables declared outside of the component/hook
40 +
41 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
42
43 error.invalid-global-reassignment-indirect.ts:9:4
44 7 |
45 8 | const setGlobal = () => {
46 > 9 | someGlobal = true;
45 - | ^^^^^^^^^^ 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)
47 + | ^^^^^^^^^^ Cannot reassign variable
48 10 | };
49 11 | const indirectSetGlobal = () => {
50 12 | setGlobal();
49 -
50 -
51 ```
52
53
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-hoisting-setstate.expect.md
+5 -12
@@ -38,35 +38,28 @@ export const FIXTURE_ENTRYPOINT = {
38 ## Error
39
40 ```
41 -Found 2 errors:
42 -Error: This variable is accessed before it is declared, which may prevent it from updating as the assigned value changes over time
41 +Found 1 error:
42 +Error: Cannot access variable before it is declared
43
44 -Variable `setState` is accessed before it is declared.
44 +Variable `setState` is accessed before it is declared, which prevents the earlier access from updating when this value changes over time
45
46 error.invalid-hoisting-setstate.ts:19:18
47 17 | * $2 = Function context=setState
48 18 | */
49 > 19 | useEffect(() => setState(2), []);
50 - | ^^^^^^^^ This variable is accessed before it is declared, which may prevent it from updating as the assigned value changes over time
50 + | ^^^^^^^^ Variable accessed before it is declared
51 20 |
52 21 | const [state, setState] = useState(0);
53 22 | return <Stringify state={state} />;
54
55 -
56 -Error: This variable is accessed before it is declared, which prevents the earlier access from updating when this value changes over time
57 -
58 -Variable `setState` is accessed before it is declared.
59 -
55 error.invalid-hoisting-setstate.ts:21:16
56 19 | useEffect(() => setState(2), []);
57 20 |
58 > 21 | const [state, setState] = useState(0);
64 - | ^^^^^^^^ This variable is accessed before it is declared, which prevents the earlier access from updating when this value changes over time
59 + | ^^^^^^^^ The variable is declared here
60 22 | return <Stringify state={state} />;
61 23 | }
62 24 |
68 -
69 -
63 ```
64
65
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-impure-functions-in-render.expect.md
+9 -15
@@ -18,48 +18,42 @@ function Component() {
18
19 ```
20 Found 3 errors:
21 -Error: 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)
21 +Error: Cannot call impure function during render
22
23 -`Date.now` is an impure function whose results may change on every call.
23 +`Date.now` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)
24
25 error.invalid-impure-functions-in-render.ts:4:15
26 2 |
27 3 | function Component() {
28 > 4 | const date = Date.now();
29 - | ^^^^^^^^^^ 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)
29 + | ^^^^^^^^^^ Cannot call impure function
30 5 | const now = performance.now();
31 6 | const rand = Math.random();
32 7 | return <Foo date={date} now={now} rand={rand} />;
33 +Error: Cannot call impure function during render
34
34 -
35 -Error: 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)
36 -
37 -`performance.now` is an impure function whose results may change on every call.
35 +`performance.now` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)
36
37 error.invalid-impure-functions-in-render.ts:5:14
38 3 | function Component() {
39 4 | const date = Date.now();
40 > 5 | const now = performance.now();
43 - | ^^^^^^^^^^^^^^^^^ 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)
41 + | ^^^^^^^^^^^^^^^^^ Cannot call impure function
42 6 | const rand = Math.random();
43 7 | return <Foo date={date} now={now} rand={rand} />;
44 8 | }
45 +Error: Cannot call impure function during render
46
48 -
49 -Error: 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)
50 -
51 -`Math.random` is an impure function whose results may change on every call.
47 +`Math.random` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)
48
49 error.invalid-impure-functions-in-render.ts:6:15
50 4 | const date = Date.now();
51 5 | const now = performance.now();
52 > 6 | const rand = Math.random();
57 - | ^^^^^^^^^^^^^ 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)
53 + | ^^^^^^^^^^^^^ Cannot call impure function
54 7 | return <Foo date={date} now={now} rand={rand} />;
55 8 | }
56 9 |
61 -
62 -
57 ```
58
59
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-jsx-captures-context-variable.expect.md
+3 -5
@@ -51,20 +51,18 @@ export const FIXTURE_ENTRYPOINT = {
51
52 ```
53 Found 1 error:
54 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
54 +Error: This value cannot be modified
55
56 -Found mutation of `i`.
56 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
57
58 error.invalid-jsx-captures-context-variable.ts:22:2
59 20 | />
60 21 | );
61 > 22 | i = i + 1;
62 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
62 + | ^ `i` cannot be modified
63 23 | items.push(
64 24 | <Stringify
65 25 | key={i}
66 -
67 -
66 ```
67
68
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-after-aliased-freeze.expect.md
+4 -4
@@ -26,18 +26,18 @@ function Component(props) {
26
27 ```
28 Found 1 error:
29 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
29 +Error: This value cannot be modified
30 +
31 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
32
33 error.invalid-mutate-after-aliased-freeze.ts:13:2
34 11 | // y is MaybeFrozen at this point, since it may alias to x
35 12 | // (which is the above line freezes)
36 > 13 | y.push(props.p2);
35 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
37 + | ^ This value cannot be modified
38 14 |
39 15 | return <Component x={x} y={y} />;
40 16 | }
39 -
40 -
41 ```
42
43
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-after-freeze.expect.md
+4 -4
@@ -20,18 +20,18 @@ function Component(props) {
20
21 ```
22 Found 1 error:
23 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
23 +Error: This value cannot be modified
24 +
25 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
26
27 error.invalid-mutate-after-freeze.ts:7:2
28 5 |
29 6 | // x is Frozen at this point
30 > 7 | x.push(props.p2);
29 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
31 + | ^ This value cannot be modified
32 8 |
33 9 | return <div>{_}</div>;
34 10 | }
33 -
34 -
35 ```
36
37
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-context-in-callback.expect.md
+3 -5
@@ -25,20 +25,18 @@ function Component(props) {
25
26 ```
27 Found 1 error:
28 -Error: Mutating a value returned from 'useContext()', which should not be mutated
28 +Error: This value cannot be modified
29
30 -Found mutation of `FooContext`.
30 +Modifying a value returned from 'useContext()' is not allowed.
31
32 error.invalid-mutate-context-in-callback.ts:12:4
33 10 | // independently
34 11 | const onClick = () => {
35 > 12 | FooContext.current = true;
36 - | ^^^^^^^^^^ Mutating a value returned from 'useContext()', which should not be mutated
36 + | ^^^^^^^^^^ `FooContext` cannot be modified
37 13 | };
38 14 | return <div onClick={onClick} />;
39 15 | }
40 -
41 -
40 ```
41
42
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-context.expect.md
+4 -4
@@ -15,18 +15,18 @@ function Component(props) {
15
16 ```
17 Found 1 error:
18 -Error: Mutating a value returned from 'useContext()', which should not be mutated
18 +Error: This value cannot be modified
19 +
20 +Modifying a value returned from 'useContext()' is not allowed.
21
22 error.invalid-mutate-context.ts:3:2
23 1 | function Component(props) {
24 2 | const context = useContext(FooContext);
25 > 3 | context.value = props.value;
24 - | ^^^^^^^ Mutating a value returned from 'useContext()', which should not be mutated
26 + | ^^^^^^^ This value cannot be modified
27 4 | return context.value;
28 5 | }
29 6 |
28 -
29 -
30 ```
31
32
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-props-in-effect-fixpoint.expect.md
+3 -5
@@ -26,20 +26,18 @@ function Component(props) {
26
27 ```
28 Found 1 error:
29 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
29 +Error: This value cannot be modified
30
31 -Found mutation of `y`.
31 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
32
33 error.invalid-mutate-props-in-effect-fixpoint.ts:10:4
34 8 | let y = x;
35 9 | let mutateProps = () => {
36 > 10 | y.foo = true;
37 - | ^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
37 + | ^ `y` cannot be modified
38 11 | };
39 12 | let mutatePropsIndirect = () => {
40 13 | mutateProps();
41 -
42 -
41 ```
42
43
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutate-props-via-for-of-iterator.expect.md
+4 -4
@@ -18,18 +18,18 @@ function Component(props) {
18
19 ```
20 Found 1 error:
21 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
21 +Error: This value cannot be modified
22 +
23 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
24
25 error.invalid-mutate-props-via-for-of-iterator.ts:4:4
26 2 | const items = [];
27 3 | for (const x of props.items) {
28 > 4 | x.modified = true;
27 - | ^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
29 + | ^ This value cannot be modified
30 5 | items.push(x);
31 6 | }
32 7 | return items;
31 -
32 -
33 ```
34
35
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutation-in-closure.expect.md
+3 -5
@@ -17,20 +17,18 @@ function useInvalidMutation(options) {
17
18 ```
19 Found 1 error:
20 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
20 +Error: This value cannot be modified
21
22 -Found mutation of `options`.
22 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
23
24 error.invalid-mutation-in-closure.ts:4:4
25 2 | function test() {
26 3 | foo(options.foo); // error should not point on this line
27 > 4 | options.foo = 'bar';
28 - | ^^^^^^^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
28 + | ^^^^^^^ `options` cannot be modified
29 5 | }
30 6 | return test;
31 7 | }
32 -
33 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-mutation-of-possible-props-phi-indirect.expect.md
+3 -5
@@ -20,20 +20,18 @@ function Component(props) {
20
21 ```
22 Found 1 error:
23 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
23 +Error: This value cannot be modified
24
25 -Found mutation of `x`.
25 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
26
27 error.invalid-mutation-of-possible-props-phi-indirect.ts:4:4
28 2 | let x = cond ? someGlobal : props.foo;
29 3 | const mutatePhiThatCouldBeProps = () => {
30 > 4 | x.y = true;
31 - | ^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
31 + | ^ `x` cannot be modified
32 5 | };
33 6 | const indirectMutateProps = () => {
34 7 | mutatePhiThatCouldBeProps();
35 -
36 -
35 ```
36
37
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-non-imported-reanimated-shared-value-writes.expect.md
+3 -5
@@ -25,20 +25,18 @@ function SomeComponent() {
25
26 ```
27 Found 1 error:
28 -Error: Updating a value returned from a hook is not allowed. Consider moving the mutation into the hook where the value is constructed
28 +Error: This value cannot be modified
29
30 -Found mutation of `sharedVal`.
30 +Modifying a value returned from a hook is not allowed. Consider moving the modification into the hook where the value is constructed
31
32 error.invalid-non-imported-reanimated-shared-value-writes.ts:11:22
33 9 | return (
34 10 | <Button
35 > 11 | onPress={() => (sharedVal.value = Math.random())}
36 - | ^^^^^^^^^ Updating a value returned from a hook is not allowed. Consider moving the mutation into the hook where the value is constructed
36 + | ^^^^^^^^^ `sharedVal` cannot be modified
37 12 | title="Randomize"
38 13 | />
39 14 | );
40 -
41 -
40 ```
41
42
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-prop-mutation-indirect.expect.md
+3 -5
@@ -19,20 +19,18 @@ function Component(props) {
19
20 ```
21 Found 1 error:
22 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
22 +Error: This value cannot be modified
23
24 -Found mutation of `props`.
24 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
25
26 error.invalid-prop-mutation-indirect.ts:3:4
27 1 | function Component(props) {
28 2 | const f = () => {
29 > 3 | props.value = true;
30 - | ^^^^^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
30 + | ^^^^^ `props` cannot be modified
31 4 | };
32 5 | const g = () => {
33 6 | f();
34 -
35 -
34 ```
35
36
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-property-store-to-frozen-value.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Component(props) {
17
18 ```
19 Found 1 error:
20 -Error: Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
20 +Error: This value cannot be modified
21 +
22 +Modifying a value used previously in JSX is not allowed. Consider moving the modification before the JSX
23
24 error.invalid-property-store-to-frozen-value.ts:5:2
25 3 | // freeze
26 4 | <div>{x}</div>;
27 > 5 | x.y = true;
26 - | ^ Updating a value used previously in JSX is not allowed. Consider moving the mutation before the JSX
28 + | ^ This value cannot be modified
29 6 | return x;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.invalid-props-mutation-in-effect-indirect.expect.md
+3 -5
@@ -19,20 +19,18 @@ function Component(props) {
19
20 ```
21 Found 1 error:
22 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
22 +Error: This value cannot be modified
23
24 -Found mutation of `props`.
24 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
25
26 error.invalid-props-mutation-in-effect-indirect.ts:3:4
27 1 | function Component(props) {
28 2 | const mutateProps = () => {
29 > 3 | props.value = true;
30 - | ^^^^^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
30 + | ^^^^^ `props` cannot be modified
31 4 | };
32 5 | const indirectMutateProps = () => {
33 6 | mutateProps();
34 -
35 -
34 ```
35
36
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.modify-state-2.expect.md
+4 -4
@@ -18,18 +18,18 @@ function Foo() {
18
19 ```
20 Found 1 error:
21 -Error: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead
21 +Error: This value cannot be modified
22 +
23 +Modifying a value returned from 'useState()', which should not be modified directly. Use the setter function to update instead
24
25 error.modify-state-2.ts:6:2
26 4 | const [state, setState] = useState({foo: {bar: 3}});
27 5 | const foo = state.foo;
28 > 6 | foo.bar = 1;
27 - | ^^^ Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead
29 + | ^^^ This value cannot be modified
30 7 | return state;
31 8 | }
32 9 |
31 -
32 -
33 ```
34
35
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.modify-state.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Foo() {
17
18 ```
19 Found 1 error:
20 -Error: Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead
20 +Error: This value cannot be modified
21 +
22 +Modifying a value returned from 'useState()', which should not be modified directly. Use the setter function to update instead
23
24 error.modify-state.ts:5:2
25 3 | function Foo() {
26 4 | let [state, setState] = useState({});
27 > 5 | state.foo = 1;
26 - | ^^^^^ Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead
28 + | ^^^^^ This value cannot be modified
29 6 | return state;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.modify-useReducer-state.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Foo() {
17
18 ```
19 Found 1 error:
20 -Error: Mutating a value returned from 'useReducer()', which should not be mutated. Use the dispatch function to update instead
20 +Error: This value cannot be modified
21 +
22 +Modifying a value returned from 'useReducer()', which should not be modified directly. Use the dispatch function to update instead
23
24 error.modify-useReducer-state.ts:5:2
25 3 | function Foo() {
26 4 | let [state, setState] = useReducer({foo: 1});
27 > 5 | state.foo = 1;
26 - | ^^^^^ Mutating a value returned from 'useReducer()', which should not be mutated. Use the dispatch function to update instead
28 + | ^^^^^ This value cannot be modified
29 6 | return state;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.mutate-function-property.expect.md
+4 -4
@@ -16,18 +16,18 @@ export function ViewModeSelector(props) {
16
17 ```
18 Found 1 error:
19 -Error: This mutates a variable that React considers immutable
19 +Error: This value cannot be modified
20 +
21 +This modifies a variable that React considers immutable
22
23 error.mutate-function-property.ts:3:2
24 1 | export function ViewModeSelector(props) {
25 2 | const renderIcon = () => <AcceptIcon />;
26 > 3 | renderIcon.displayName = 'AcceptIcon';
25 - | ^^^^^^^^^^ This mutates a variable that React considers immutable
27 + | ^^^^^^^^^^ This value cannot be modified
28 4 |
29 5 | return <Dropdown checkableIndicator={{children: renderIcon}} />;
30 6 | }
29 -
30 -
31 ```
32
33
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.mutate-hook-argument.expect.md
+7 -7
@@ -14,28 +14,28 @@ function useHook(a, b) {
14
15 ```
16 Found 2 errors:
17 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
17 +Error: This value cannot be modified
18 +
19 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
20
21 error.mutate-hook-argument.ts:2:2
22 1 | function useHook(a, b) {
23 > 2 | b.test = 1;
22 - | ^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
24 + | ^ This value cannot be modified
25 3 | a.test = 2;
26 4 | }
27 5 |
28 +Error: This value cannot be modified
29
27 -
28 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
30 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
31
32 error.mutate-hook-argument.ts:3:2
33 1 | function useHook(a, b) {
34 2 | b.test = 1;
35 > 3 | a.test = 2;
34 - | ^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
36 + | ^ This value cannot be modified
37 4 | }
38 5 |
37 -
38 -
39 ```
40
41
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.mutate-property-from-global.expect.md
+4 -4
@@ -16,18 +16,18 @@ function Foo() {
16
17 ```
18 Found 1 error:
19 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
19 +Error: This value cannot be modified
20 +
21 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
22
23 error.mutate-property-from-global.ts:4:9
24 2 |
25 3 | function Foo() {
26 > 4 | delete wat.foo;
25 - | ^^^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
27 + | ^^^ This value cannot be modified
28 5 | return wat;
29 6 | }
30 7 |
29 -
30 -
31 ```
32
33
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.mutate-props.expect.md
+4 -4
@@ -14,17 +14,17 @@ function Foo(props) {
14
15 ```
16 Found 1 error:
17 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
17 +Error: This value cannot be modified
18 +
19 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
20
21 error.mutate-props.ts:2:2
22 1 | function Foo(props) {
23 > 2 | props.test = 1;
22 - | ^^^^^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
24 + | ^^^^^ This value cannot be modified
25 3 | return null;
26 4 | }
27 5 |
26 -
27 -
28 ```
29
30
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.not-useEffect-external-mutate.expect.md
+7 -7
@@ -18,30 +18,30 @@ function Component(props) {
18
19 ```
20 Found 2 errors:
21 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
21 +Error: This value cannot be modified
22 +
23 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
24
25 error.not-useEffect-external-mutate.ts:5:4
26 3 | function Component(props) {
27 4 | foo(() => {
28 > 5 | x.a = 10;
27 - | ^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
29 + | ^ This value cannot be modified
30 6 | x.a = 20;
31 7 | });
32 8 | }
33 +Error: This value cannot be modified
34
32 -
33 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
35 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
36
37 error.not-useEffect-external-mutate.ts:6:4
38 4 | foo(() => {
39 5 | x.a = 10;
40 > 6 | x.a = 20;
39 - | ^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
41 + | ^ This value cannot be modified
42 7 | });
43 8 | }
44 9 |
43 -
44 -
45 ```
46
47
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.object-capture-global-mutation.expect.md
+2 -2
@@ -23,13 +23,13 @@ export const FIXTURE_ENTRYPOINT = {
23
24 ```
25 Found 1 error:
26 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
26 +Error: Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
27
28 error.object-capture-global-mutation.ts:4:4
29 2 | function Foo() {
30 3 | const x = () => {
31 > 4 | window.href = 'foo';
32 - | ^^^^^^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
32 + | ^^^^^^ Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
33 5 | };
34 6 | const y = {x};
35 7 | return <Bar y={y} />;
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.reassign-global-fn-arg.expect.md
+4 -4
@@ -25,18 +25,18 @@ export const FIXTURE_ENTRYPOINT = {
25
26 ```
27 Found 1 error:
28 -Error: 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)
28 +Error: Cannot reassign variables declared outside of the component/hook
29 +
30 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
31
32 error.reassign-global-fn-arg.ts:5:4
33 3 | export default function MyApp() {
34 4 | const fn = () => {
35 > 5 | b = 2;
34 - | ^ 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)
36 + | ^ Cannot reassign variable
37 6 | };
38 7 | return foo(fn);
39 8 | }
38 -
39 -
40 ```
41
42
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.reassignment-to-global-indirect.expect.md
+7 -7
@@ -18,30 +18,30 @@ function Component() {
18
19 ```
20 Found 2 errors:
21 -Error: 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)
21 +Error: Cannot reassign variables declared outside of the component/hook
22 +
23 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
24
25 error.reassignment-to-global-indirect.ts:4:4
26 2 | const foo = () => {
27 3 | // Cannot assign to globals
28 > 4 | someUnknownGlobal = true;
27 - | ^^^^^^^^^^^^^^^^^ 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)
29 + | ^^^^^^^^^^^^^^^^^ Cannot reassign variable
30 5 | moduleLocal = true;
31 6 | };
32 7 | foo();
33 +Error: Cannot reassign variables declared outside of the component/hook
34
32 -
33 -Error: 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)
35 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
36
37 error.reassignment-to-global-indirect.ts:5:4
38 3 | // Cannot assign to globals
39 4 | someUnknownGlobal = true;
40 > 5 | moduleLocal = true;
39 - | ^^^^^^^^^^^ 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)
41 + | ^^^^^^^^^^^ Cannot reassign variable
42 6 | };
43 7 | foo();
44 8 | }
43 -
44 -
45 ```
46
47
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.reassignment-to-global.expect.md
+7 -7
@@ -15,29 +15,29 @@ function Component() {
15
16 ```
17 Found 2 errors:
18 -Error: 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)
18 +Error: Cannot reassign variables declared outside of the component/hook
19 +
20 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
21
22 error.reassignment-to-global.ts:3:2
23 1 | function Component() {
24 2 | // Cannot assign to globals
25 > 3 | someUnknownGlobal = true;
24 - | ^^^^^^^^^^^^^^^^^ 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)
26 + | ^^^^^^^^^^^^^^^^^ Cannot reassign variable
27 4 | moduleLocal = true;
28 5 | }
29 6 |
30 +Error: Cannot reassign variables declared outside of the component/hook
31
29 -
30 -Error: 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)
32 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
33
34 error.reassignment-to-global.ts:4:2
35 2 | // Cannot assign to globals
36 3 | someUnknownGlobal = true;
37 > 4 | moduleLocal = true;
36 - | ^^^^^^^^^^^ 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)
38 + | ^^^^^^^^^^^ Cannot reassign variable
39 5 | }
40 6 |
39 -
40 -
41 ```
42
43
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.store-property-in-global.expect.md
+4 -4
@@ -16,18 +16,18 @@ function Foo() {
16
17 ```
18 Found 1 error:
19 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
19 +Error: This value cannot be modified
20 +
21 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
22
23 error.store-property-in-global.ts:4:2
24 2 |
25 3 | function Foo() {
26 > 4 | wat.test = 1;
25 - | ^^^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
27 + | ^^^ This value cannot be modified
28 5 | return wat;
29 6 | }
30 7 |
29 -
30 -
31 ```
32
33
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.update-global-should-bailout.expect.md
+4 -4
@@ -20,18 +20,18 @@ export const FIXTURE_ENTRYPOINT = {
20
21 ```
22 Found 1 error:
23 -Error: 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)
23 +Error: Cannot reassign variables declared outside of the component/hook
24 +
25 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
26
27 error.update-global-should-bailout.ts:3:2
28 1 | let renderCount = 0;
29 2 | function useFoo() {
30 > 3 | renderCount += 1;
29 - | ^^^^^^^^^^^^^^^^ 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)
31 + | ^^^^^^^^^^^^^^^^ Cannot reassign variable
32 4 | return renderCount;
33 5 | }
34 6 |
33 -
34 -
35 ```
36
37
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/mutate-after-useeffect-optional-chain.expect.md
+1 -1
@@ -48,7 +48,7 @@ export const FIXTURE_ENTRYPOINT = {
48 ## Logs
49
50 ```
51 -{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":149},"end":{"line":12,"column":1,"index":404},"filename":"mutate-after-useeffect-optional-chain.ts"},"detail":{"options":{"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":365},"end":{"line":10,"column":5,"index":368},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}}}}
51 +{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":149},"end":{"line":12,"column":1,"index":404},"filename":"mutate-after-useeffect-optional-chain.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the modification before calling useEffect()","details":[{"kind":"error","loc":{"start":{"line":10,"column":2,"index":365},"end":{"line":10,"column":5,"index":368},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"},"message":"This value cannot be modified"}]}}}
52 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":9,"column":2,"index":314},"end":{"line":9,"column":49,"index":361},"filename":"mutate-after-useeffect-optional-chain.ts"},"decorations":[{"start":{"line":9,"column":24,"index":336},"end":{"line":9,"column":27,"index":339},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}]}
53 {"kind":"CompileSuccess","fnLoc":{"start":{"line":5,"column":0,"index":149},"end":{"line":12,"column":1,"index":404},"filename":"mutate-after-useeffect-optional-chain.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
54 ```
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/mutate-after-useeffect-ref-access.expect.md
+1 -1
@@ -47,7 +47,7 @@ export const FIXTURE_ENTRYPOINT = {
47 ## Logs
48
49 ```
50 -{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":158},"end":{"line":11,"column":1,"index":331},"filename":"mutate-after-useeffect-ref-access.ts"},"detail":{"options":{"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":289},"end":{"line":9,"column":16,"index":303},"filename":"mutate-after-useeffect-ref-access.ts"}}}}
50 +{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":158},"end":{"line":11,"column":1,"index":331},"filename":"mutate-after-useeffect-ref-access.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying component props or hook arguments is not allowed. Consider using a local variable instead","details":[{"kind":"error","loc":{"start":{"line":9,"column":2,"index":289},"end":{"line":9,"column":16,"index":303},"filename":"mutate-after-useeffect-ref-access.ts"},"message":"This value cannot be modified"}]}}}
51 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":8,"column":2,"index":237},"end":{"line":8,"column":50,"index":285},"filename":"mutate-after-useeffect-ref-access.ts"},"decorations":[{"start":{"line":8,"column":24,"index":259},"end":{"line":8,"column":30,"index":265},"filename":"mutate-after-useeffect-ref-access.ts","identifierName":"arrRef"}]}
52 {"kind":"CompileSuccess","fnLoc":{"start":{"line":6,"column":0,"index":158},"end":{"line":11,"column":1,"index":331},"filename":"mutate-after-useeffect-ref-access.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
53 ```
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/bailout-retry/mutate-after-useeffect.expect.md
+1 -1
@@ -47,7 +47,7 @@ export const FIXTURE_ENTRYPOINT = {
47 ## Logs
48
49 ```
50 -{"kind":"CompileError","fnLoc":{"start":{"line":4,"column":0,"index":111},"end":{"line":11,"column":1,"index":242},"filename":"mutate-after-useeffect.ts"},"detail":{"options":{"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":214},"end":{"line":9,"column":5,"index":217},"filename":"mutate-after-useeffect.ts","identifierName":"arr"}}}}
50 +{"kind":"CompileError","fnLoc":{"start":{"line":4,"column":0,"index":111},"end":{"line":11,"column":1,"index":242},"filename":"mutate-after-useeffect.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the modification before calling useEffect()","details":[{"kind":"error","loc":{"start":{"line":9,"column":2,"index":214},"end":{"line":9,"column":5,"index":217},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},"message":"This value cannot be modified"}]}}}
51 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":6,"column":2,"index":159},"end":{"line":8,"column":14,"index":210},"filename":"mutate-after-useeffect.ts"},"decorations":[{"start":{"line":7,"column":4,"index":181},"end":{"line":7,"column":7,"index":184},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":4,"index":181},"end":{"line":7,"column":7,"index":184},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":13,"index":190},"end":{"line":7,"column":16,"index":193},"filename":"mutate-after-useeffect.ts","identifierName":"foo"}]}
52 {"kind":"CompileSuccess","fnLoc":{"start":{"line":4,"column":0,"index":111},"end":{"line":11,"column":1,"index":242},"filename":"mutate-after-useeffect.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
53 ```
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/no-emit/retry-no-emit.expect.md
+1 -1
@@ -54,7 +54,7 @@ export const FIXTURE_ENTRYPOINT = {
54 ## Logs
55
56 ```
57 -{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":195},"end":{"line":14,"column":1,"index":409},"filename":"retry-no-emit.ts"},"detail":{"options":{"reason":"Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook","description":null,"severity":"InvalidReact","suggestions":null,"loc":{"start":{"line":12,"column":2,"index":372},"end":{"line":12,"column":6,"index":376},"filename":"retry-no-emit.ts","identifierName":"arr2"}}}}
57 +{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":195},"end":{"line":14,"column":1,"index":409},"filename":"retry-no-emit.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook","details":[{"kind":"error","loc":{"start":{"line":12,"column":2,"index":372},"end":{"line":12,"column":6,"index":376},"filename":"retry-no-emit.ts","identifierName":"arr2"},"message":"This value cannot be modified"}]}}}
58 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":8,"column":2,"index":248},"end":{"line":8,"column":46,"index":292},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":8,"column":31,"index":277},"end":{"line":8,"column":34,"index":280},"filename":"retry-no-emit.ts","identifierName":"arr"}]}
59 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":11,"column":2,"index":316},"end":{"line":11,"column":54,"index":368},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":11,"column":25,"index":339},"end":{"line":11,"column":29,"index":343},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":11,"column":25,"index":339},"end":{"line":11,"column":29,"index":343},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":11,"column":35,"index":349},"end":{"line":11,"column":42,"index":356},"filename":"retry-no-emit.ts","identifierName":"propVal"}]}
60 {"kind":"CompileSuccess","fnLoc":{"start":{"line":6,"column":0,"index":195},"end":{"line":14,"column":1,"index":409},"filename":"retry-no-emit.ts"},"fnName":"Foo","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.invalid-impure-functions-in-render.expect.md
+9 -15
@@ -18,48 +18,42 @@ function Component() {
18
19 ```
20 Found 3 errors:
21 -Error: 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)
21 +Error: Cannot call impure function during render
22
23 -`Date.now` is an impure function whose results may change on every call.
23 +`Date.now` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)
24
25 error.invalid-impure-functions-in-render.ts:4:15
26 2 |
27 3 | function Component() {
28 > 4 | const date = Date.now();
29 - | ^^^^^^^^^^ 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)
29 + | ^^^^^^^^^^ Cannot call impure function
30 5 | const now = performance.now();
31 6 | const rand = Math.random();
32 7 | return <Foo date={date} now={now} rand={rand} />;
33 +Error: Cannot call impure function during render
34
34 -
35 -Error: 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)
36 -
37 -`performance.now` is an impure function whose results may change on every call.
35 +`performance.now` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)
36
37 error.invalid-impure-functions-in-render.ts:5:14
38 3 | function Component() {
39 4 | const date = Date.now();
40 > 5 | const now = performance.now();
43 - | ^^^^^^^^^^^^^^^^^ 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)
41 + | ^^^^^^^^^^^^^^^^^ Cannot call impure function
42 6 | const rand = Math.random();
43 7 | return <Foo date={date} now={now} rand={rand} />;
44 8 | }
45 +Error: Cannot call impure function during render
46
48 -
49 -Error: 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)
50 -
51 -`Math.random` is an impure function whose results may change on every call.
47 +`Math.random` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent)
48
49 error.invalid-impure-functions-in-render.ts:6:15
50 4 | const date = Date.now();
51 5 | const now = performance.now();
52 > 6 | const rand = Math.random();
57 - | ^^^^^^^^^^^^^ 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)
53 + | ^^^^^^^^^^^^^ Cannot call impure function
54 7 | return <Foo date={date} now={now} rand={rand} />;
55 8 | }
56 9 |
61 -
62 -
57 ```
58
59
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.invalid-referencing-frozen-hoisted-storecontext-const.expect.md
+5 -12
@@ -31,35 +31,28 @@ function Component({content, refetch}) {
31 ## Error
32
33 ```
34 -Found 2 errors:
35 -Error: This variable is accessed before it is declared, which may prevent it from updating as the assigned value changes over time
34 +Found 1 error:
35 +Error: Cannot access variable before it is declared
36
37 -Variable `data` is accessed before it is declared.
37 +Variable `data` is accessed before it is declared, which prevents the earlier access from updating when this value changes over time
38
39 undefined:11:12
40 9 | // TDZ violation!
41 10 | const onRefetch = useCallback(() => {
42 > 11 | refetch(data);
43 - | ^^^^ This variable is accessed before it is declared, which may prevent it from updating as the assigned value changes over time
43 + | ^^^^ Variable accessed before it is declared
44 12 | }, [refetch]);
45 13 |
46 14 | // The context variable gets frozen here since it's passed to a hook
47
48 -
49 -Error: This variable is accessed before it is declared, which prevents the earlier access from updating when this value changes over time
50 -
51 -Variable `data` is accessed before it is declared.
52 -
48 undefined:19:9
49 17 | // This has to error: onRefetch needs to memoize with `content` as a
50 18 | // dependency, but the dependency comes later
51 > 19 | const {data = null} = content;
57 - | ^^^^^^^^^^^ This variable is accessed before it is declared, which prevents the earlier access from updating when this value changes over time
52 + | ^^^^^^^^^^^ The variable is declared here
53 20 |
54 21 | return <Foo data={data} onSubmit={onSubmit} />;
55 22 | }
61 -
62 -
56 ```
57
58
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.mutate-frozen-value.expect.md
+4 -4
@@ -17,18 +17,18 @@ function Component({a, b}) {
17
18 ```
19 Found 1 error:
20 -Error: Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook
20 +Error: This value cannot be modified
21 +
22 +Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook
23
24 error.mutate-frozen-value.ts:5:2
25 3 | const x = {a};
26 4 | useFreeze(x);
27 > 5 | x.y = true;
26 - | ^ Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook
28 + | ^ This value cannot be modified
29 6 | return <div>error</div>;
30 7 | }
31 8 |
30 -
31 -
32 ```
33
34
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.mutate-hook-argument.expect.md
+7 -7
@@ -15,29 +15,29 @@ function useHook(a, b) {
15
16 ```
17 Found 2 errors:
18 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
18 +Error: This value cannot be modified
19 +
20 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
21
22 error.mutate-hook-argument.ts:3:2
23 1 | // @enableNewMutationAliasingModel
24 2 | function useHook(a, b) {
25 > 3 | b.test = 1;
24 - | ^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
26 + | ^ This value cannot be modified
27 4 | a.test = 2;
28 5 | }
29 6 |
30 +Error: This value cannot be modified
31
29 -
30 -Error: Mutating component props or hook arguments is not allowed. Consider using a local variable instead
32 +Modifying component props or hook arguments is not allowed. Consider using a local variable instead
33
34 error.mutate-hook-argument.ts:4:2
35 2 | function useHook(a, b) {
36 3 | b.test = 1;
37 > 4 | a.test = 2;
36 - | ^ Mutating component props or hook arguments is not allowed. Consider using a local variable instead
38 + | ^ This value cannot be modified
39 5 | }
40 6 |
39 -
40 -
41 ```
42
43
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.not-useEffect-external-mutate.expect.md
+7 -7
@@ -19,30 +19,30 @@ function Component(props) {
19
20 ```
21 Found 2 errors:
22 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
22 +Error: This value cannot be modified
23 +
24 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
25
26 error.not-useEffect-external-mutate.ts:6:4
27 4 | function Component(props) {
28 5 | foo(() => {
29 > 6 | x.a = 10;
28 - | ^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
30 + | ^ This value cannot be modified
31 7 | x.a = 20;
32 8 | });
33 9 | }
34 +Error: This value cannot be modified
35
33 -
34 -Error: Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
36 +Modifying a variable defined outside a component or hook is not allowed. Consider using an effect
37
38 error.not-useEffect-external-mutate.ts:7:4
39 5 | foo(() => {
40 6 | x.a = 10;
41 > 7 | x.a = 20;
40 - | ^ Writing to a variable defined outside a component or hook is not allowed. Consider using an effect
42 + | ^ This value cannot be modified
43 8 | });
44 9 | }
45 10 |
44 -
45 -
46 ```
47
48
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.reassignment-to-global-indirect.expect.md
+7 -7
@@ -19,30 +19,30 @@ function Component() {
19
20 ```
21 Found 2 errors:
22 -Error: 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)
22 +Error: Cannot reassign variables declared outside of the component/hook
23 +
24 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
25
26 error.reassignment-to-global-indirect.ts:5:4
27 3 | const foo = () => {
28 4 | // Cannot assign to globals
29 > 5 | someUnknownGlobal = true;
28 - | ^^^^^^^^^^^^^^^^^ 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)
30 + | ^^^^^^^^^^^^^^^^^ Cannot reassign variable
31 6 | moduleLocal = true;
32 7 | };
33 8 | foo();
34 +Error: Cannot reassign variables declared outside of the component/hook
35
33 -
34 -Error: 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)
36 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
37
38 error.reassignment-to-global-indirect.ts:6:4
39 4 | // Cannot assign to globals
40 5 | someUnknownGlobal = true;
41 > 6 | moduleLocal = true;
40 - | ^^^^^^^^^^^ 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)
42 + | ^^^^^^^^^^^ Cannot reassign variable
43 7 | };
44 8 | foo();
45 9 | }
44 -
45 -
46 ```
47
48
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/error.reassignment-to-global.expect.md
+7 -7
@@ -16,29 +16,29 @@ function Component() {
16
17 ```
18 Found 2 errors:
19 -Error: 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)
19 +Error: Cannot reassign variables declared outside of the component/hook
20 +
21 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
22
23 error.reassignment-to-global.ts:4:2
24 2 | function Component() {
25 3 | // Cannot assign to globals
26 > 4 | someUnknownGlobal = true;
25 - | ^^^^^^^^^^^^^^^^^ 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)
27 + | ^^^^^^^^^^^^^^^^^ Cannot reassign variable
28 5 | moduleLocal = true;
29 6 | }
30 7 |
31 +Error: Cannot reassign variables declared outside of the component/hook
32
30 -
31 -Error: 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)
33 +Reassigning a variable declared outside of the component/hook is a form of side effect, which can cause unpredictable behavior depending on when the component happens to re-render. If this variable is used in rendering, use useState instead. Otherwise, consider updating it in an effect (https://react.dev/reference/rules/components-and-hooks-must-be-pure#side-effects-must-run-outside-of-render)
34
35 error.reassignment-to-global.ts:5:2
36 3 | // Cannot assign to globals
37 4 | someUnknownGlobal = true;
38 > 5 | moduleLocal = true;
37 - | ^^^^^^^^^^^ 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)
39 + | ^^^^^^^^^^^ Cannot reassign variable
40 6 | }
41 7 |
40 -
41 -
42 ```
43
44
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-after-useeffect-optional-chain.expect.md
+1 -1
@@ -48,7 +48,7 @@ export const FIXTURE_ENTRYPOINT = {
48 ## Logs
49
50 ```
51 -{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":181},"end":{"line":12,"column":1,"index":436},"filename":"mutate-after-useeffect-optional-chain.ts"},"detail":{"options":{"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":397},"end":{"line":10,"column":5,"index":400},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}}}}
51 +{"kind":"CompileError","fnLoc":{"start":{"line":5,"column":0,"index":181},"end":{"line":12,"column":1,"index":436},"filename":"mutate-after-useeffect-optional-chain.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the modification before calling useEffect()","details":[{"kind":"error","loc":{"start":{"line":10,"column":2,"index":397},"end":{"line":10,"column":5,"index":400},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"},"message":"This value cannot be modified"}]}}}
52 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":9,"column":2,"index":346},"end":{"line":9,"column":49,"index":393},"filename":"mutate-after-useeffect-optional-chain.ts"},"decorations":[{"start":{"line":9,"column":24,"index":368},"end":{"line":9,"column":27,"index":371},"filename":"mutate-after-useeffect-optional-chain.ts","identifierName":"arr"}]}
53 {"kind":"CompileSuccess","fnLoc":{"start":{"line":5,"column":0,"index":181},"end":{"line":12,"column":1,"index":436},"filename":"mutate-after-useeffect-optional-chain.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
54 ```
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-after-useeffect-ref-access.expect.md
+1 -1
@@ -47,7 +47,7 @@ export const FIXTURE_ENTRYPOINT = {
47 ## Logs
48
49 ```
50 -{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":190},"end":{"line":11,"column":1,"index":363},"filename":"mutate-after-useeffect-ref-access.ts"},"detail":{"options":{"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":321},"end":{"line":9,"column":16,"index":335},"filename":"mutate-after-useeffect-ref-access.ts"}}}}
50 +{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":190},"end":{"line":11,"column":1,"index":363},"filename":"mutate-after-useeffect-ref-access.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying component props or hook arguments is not allowed. Consider using a local variable instead","details":[{"kind":"error","loc":{"start":{"line":9,"column":2,"index":321},"end":{"line":9,"column":16,"index":335},"filename":"mutate-after-useeffect-ref-access.ts"},"message":"This value cannot be modified"}]}}}
51 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":8,"column":2,"index":269},"end":{"line":8,"column":50,"index":317},"filename":"mutate-after-useeffect-ref-access.ts"},"decorations":[{"start":{"line":8,"column":24,"index":291},"end":{"line":8,"column":30,"index":297},"filename":"mutate-after-useeffect-ref-access.ts","identifierName":"arrRef"}]}
52 {"kind":"CompileSuccess","fnLoc":{"start":{"line":6,"column":0,"index":190},"end":{"line":11,"column":1,"index":363},"filename":"mutate-after-useeffect-ref-access.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
53 ```
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/mutate-after-useeffect.expect.md
+1 -1
@@ -47,7 +47,7 @@ export const FIXTURE_ENTRYPOINT = {
47 ## Logs
48
49 ```
50 -{"kind":"CompileError","fnLoc":{"start":{"line":4,"column":0,"index":143},"end":{"line":11,"column":1,"index":274},"filename":"mutate-after-useeffect.ts"},"detail":{"options":{"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":246},"end":{"line":9,"column":5,"index":249},"filename":"mutate-after-useeffect.ts","identifierName":"arr"}}}}
50 +{"kind":"CompileError","fnLoc":{"start":{"line":4,"column":0,"index":143},"end":{"line":11,"column":1,"index":274},"filename":"mutate-after-useeffect.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying a value used previously in an effect function or as an effect dependency is not allowed. Consider moving the modification before calling useEffect()","details":[{"kind":"error","loc":{"start":{"line":9,"column":2,"index":246},"end":{"line":9,"column":5,"index":249},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},"message":"This value cannot be modified"}]}}}
51 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":6,"column":2,"index":191},"end":{"line":8,"column":14,"index":242},"filename":"mutate-after-useeffect.ts"},"decorations":[{"start":{"line":7,"column":4,"index":213},"end":{"line":7,"column":7,"index":216},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":4,"index":213},"end":{"line":7,"column":7,"index":216},"filename":"mutate-after-useeffect.ts","identifierName":"arr"},{"start":{"line":7,"column":13,"index":222},"end":{"line":7,"column":16,"index":225},"filename":"mutate-after-useeffect.ts","identifierName":"foo"}]}
52 {"kind":"CompileSuccess","fnLoc":{"start":{"line":4,"column":0,"index":143},"end":{"line":11,"column":1,"index":274},"filename":"mutate-after-useeffect.ts"},"fnName":"Component","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}
53 ```
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/new-mutability/retry-no-emit.expect.md
+1 -1
@@ -54,7 +54,7 @@ export const FIXTURE_ENTRYPOINT = {
54 ## Logs
55
56 ```
57 -{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":227},"end":{"line":14,"column":1,"index":441},"filename":"retry-no-emit.ts"},"detail":{"options":{"reason":"Updating a value previously passed as an argument to a hook is not allowed. Consider moving the mutation before calling the hook","description":null,"severity":"InvalidReact","suggestions":null,"loc":{"start":{"line":12,"column":2,"index":404},"end":{"line":12,"column":6,"index":408},"filename":"retry-no-emit.ts","identifierName":"arr2"}}}}
57 +{"kind":"CompileError","fnLoc":{"start":{"line":6,"column":0,"index":227},"end":{"line":14,"column":1,"index":441},"filename":"retry-no-emit.ts"},"detail":{"options":{"severity":"InvalidReact","category":"This value cannot be modified","description":"Modifying a value previously passed as an argument to a hook is not allowed. Consider moving the modification before calling the hook","details":[{"kind":"error","loc":{"start":{"line":12,"column":2,"index":404},"end":{"line":12,"column":6,"index":408},"filename":"retry-no-emit.ts","identifierName":"arr2"},"message":"This value cannot be modified"}]}}}
58 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":8,"column":2,"index":280},"end":{"line":8,"column":46,"index":324},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":8,"column":31,"index":309},"end":{"line":8,"column":34,"index":312},"filename":"retry-no-emit.ts","identifierName":"arr"}]}
59 {"kind":"AutoDepsDecorations","fnLoc":{"start":{"line":11,"column":2,"index":348},"end":{"line":11,"column":54,"index":400},"filename":"retry-no-emit.ts"},"decorations":[{"start":{"line":11,"column":25,"index":371},"end":{"line":11,"column":29,"index":375},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":11,"column":25,"index":371},"end":{"line":11,"column":29,"index":375},"filename":"retry-no-emit.ts","identifierName":"arr2"},{"start":{"line":11,"column":35,"index":381},"end":{"line":11,"column":42,"index":388},"filename":"retry-no-emit.ts","identifierName":"propVal"}]}
60 {"kind":"CompileSuccess","fnLoc":{"start":{"line":6,"column":0,"index":227},"end":{"line":14,"column":1,"index":441},"filename":"retry-no-emit.ts"},"fnName":"Foo","memoSlots":0,"memoBlocks":0,"memoValues":0,"prunedMemoBlocks":0,"prunedMemoValues":0}