Skip to content

Commit 3995868

Browse files
committed
Update on "[compiler] Refactor validations to return Result and log where appropriate"
Updates ~all of our validations to return a Result, and then updates callers to either unwrap() if they should bailout or else just log. [ghstack-poisoned]
2 parents 55d716d + 60fdd9a commit 3995868

File tree

8 files changed

+9
-8
lines changed

8 files changed

+9
-8
lines changed

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateHooksUsage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
eachTerminalOperand,
2727
} from '../HIR/visitors';
2828
import {assertExhaustive} from '../Utils/utils';
29-
import {Err, Ok, Result} from '../Utils/Result';
29+
import {Result} from '../Utils/Result';
3030

3131
/**
3232
* Represents the possible kinds of value which may be stored at a given Place during

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoCapitalizedCalls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import {CompilerError, EnvironmentConfig, ErrorSeverity} from '..';
88
import {HIRFunction, IdentifierId} from '../HIR';
99
import {DEFAULT_GLOBALS} from '../HIR/Globals';
10-
import {Err, Ok, Result} from '../Utils/Result';
10+
import {Result} from '../Utils/Result';
1111

1212
export function validateNoCapitalizedCalls(
1313
fn: HIRFunction,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import {CompilerError, ErrorSeverity} from '..';
99
import {HIRFunction} from '../HIR';
1010
import {getFunctionCallSignature} from '../Inference/InferReferenceEffects';
11-
import {Err, Ok, Result} from '../Utils/Result';
11+
import {Result} from '../Utils/Result';
1212

1313
/**
1414
* Checks that known-impure functions are not called during render. Examples of invalid functions to

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoJSXInTryStatement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {CompilerError, ErrorSeverity} from '..';
99
import {BlockId, HIRFunction} from '../HIR';
10-
import {Err, Ok, Result} from '../Utils/Result';
10+
import {Result} from '../Utils/Result';
1111
import {retainWhere} from '../Utils/utils';
1212

1313
/**

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoSetStateInPassiveEffects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
Place,
1515
} from '../HIR';
1616
import {eachInstructionValueOperand} from '../HIR/visitors';
17-
import {Err, Ok, Result} from '../Utils/Result';
17+
import {Result} from '../Utils/Result';
1818

1919
/**
2020
* Validates against calling setState in the body of a *passive* effect (useEffect),

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoSetStateInRender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {CompilerError, ErrorSeverity} from '../CompilerError';
99
import {HIRFunction, IdentifierId, isSetStateType} from '../HIR';
1010
import {computeUnconditionalBlocks} from '../HIR/ComputeUnconditionalBlocks';
1111
import {eachInstructionValueOperand} from '../HIR/visitors';
12-
import {Err, Ok, Result} from '../Utils/Result';
12+
import {Result} from '../Utils/Result';
1313

1414
/**
1515
* Validates that the given function does not have an infinite update loop

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidatePreservedManualMemoization.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import {CompilerError, Effect, ErrorSeverity} from '..';
8+
import {CompilerError, ErrorSeverity} from '../CompilerError';
99
import {
1010
DeclarationId,
11+
Effect,
1112
GeneratedSource,
1213
Identifier,
1314
IdentifierId,

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateStaticComponents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import {CompilerError, ErrorSeverity} from '../CompilerError';
99
import {HIRFunction, IdentifierId, SourceLocation} from '../HIR';
10-
import {Err, Ok, Result} from '../Utils/Result';
10+
import {Result} from '../Utils/Result';
1111

1212
/**
1313
* Validates against components that are created dynamically and whose identity is not guaranteed

0 commit comments

Comments
 (0)