Remove flag for enableEarlyReturnInReactiveScopes (always enable)
Joe Savona committed
Apr 1, 2024 at 15:37 UTC
f0806c43fe97a0a858416d5caadd01f6b141bed4
4 files changed
+1
-72
compiler/packages/babel-plugin-react-forget/src/HIR/Environment.ts
-10
@@ -273,16 +273,6 @@ const EnvironmentConfigSchema = z.object({
273
*/
274
enableEmitInstrumentForget: InstrumentationSchema.nullish(),
275
276
- /**
277
- * Enable support for reactive scopes that contain an early return.
278
- * This is relatively infrequent, as reactive scopes generally span
279
- * up to but excluding return statements.
280
- *
281
- * When disabled, the compiler will error (bailout) on any functions which
282
- * would create a reactive scope that contains a return statement.
283
- */
284
- enableEarlyReturnInReactiveScopes: z.boolean().default(true),
285
-
276
// Enable validation of mutable ranges
277
assertValidMutableRanges: z.boolean().default(false),
278
compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateEarlyReturns.ts
+1
-9
@@ -6,7 +6,7 @@
6
*/
7
8
import { visitReactiveFunction } from ".";
9
-import { CompilerError, Effect } from "..";
9
+import { Effect } from "..";
10
import {
11
Environment,
12
GeneratedSource,
@@ -266,14 +266,6 @@ class Transform extends ReactiveFunctionTransform<State> {
266
state: State
267
): Transformed<ReactiveStatement> {
268
if (state.withinReactiveScope && stmt.terminal.kind === "return") {
269
- if (!this.env.config.enableEarlyReturnInReactiveScopes) {
270
- CompilerError.throwTodo({
271
- reason: `Support early return within a reactive scope`,
272
- loc: stmt.terminal.value.loc,
273
- description: null,
274
- suggestions: null,
275
- });
276
- }
269
const loc = stmt.terminal.value.loc;
270
let earlyReturnValue: ReactiveScope["earlyReturnValue"];
271
if (state.earlyReturnValue !== null) {
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-early-return--early-return-within-reactive-scope.expect.md
deleted
-37
@@ -1,37 +0,0 @@
1
-
2
-## Input
3
-
4
-```javascript
5
-// @enableEarlyReturnInReactiveScopes:false
6
-function Component(props) {
7
- let x = [];
8
- if (props.cond) {
9
- x.push(props.a);
10
- // oops no memo!
11
- return x;
12
- } else {
13
- return foo();
14
- }
15
-}
16
-
17
-export const FIXTURE_ENTRYPOINT = {
18
- fn: Component,
19
- params: [{ cond: true, a: 42 }],
20
-};
21
-
22
-```
23
-
24
-
25
-## Error
26
-
27
-```
28
- 5 | x.push(props.a);
29
- 6 | // oops no memo!
30
-> 7 | return x;
31
- | ^ Todo: Support early return within a reactive scope (7:7)
32
- 8 | } else {
33
- 9 | return foo();
34
- 10 | }
35
-```
36
-
37
-
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-early-return--early-return-within-reactive-scope.js
deleted
-16
@@ -1,16 +0,0 @@
1
-// @enableEarlyReturnInReactiveScopes:false
2
-function Component(props) {
3
- let x = [];
4
- if (props.cond) {
5
- x.push(props.a);
6
- // oops no memo!
7
- return x;
8
- } else {
9
- return foo();
10
- }
11
-}
12
-
13
-export const FIXTURE_ENTRYPOINT = {
14
- fn: Component,
15
- params: [{ cond: true, a: 42 }],
16
-};