Enable early return support by default

This PR enables the new feature flag by default, but keeps the flag around so 
that we can quickly turn it off if there are issues.
This commit is contained in:
Joe Savona
2023-12-20 13:52:43 -08:00
parent fcc2182641
commit bf859705b5
19 changed files with 13 additions and 30 deletions
@@ -280,10 +280,10 @@ const EnvironmentConfigSchema = z.object({
* This is relatively infrequent, as reactive scopes generally span
* up to but excluding return statements.
*
* When disabled (default), the compiler will skip any functions which
* When disabled, the compiler will error (bailout) on any functions which
* would create a reactive scope that contains a return statement.
*/
enableEarlyReturnInReactiveScopes: z.boolean().default(false),
enableEarlyReturnInReactiveScopes: z.boolean().default(true),
// Enable validation of mutable ranges
assertValidMutableRanges: z.boolean().default(false),
@@ -2,8 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
/**
* props.b does *not* influence `a`
*/
@@ -68,8 +66,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
/**
* props.b does *not* influence `a`
*/
@@ -1,5 +1,3 @@
// @enableEarlyReturnInReactiveScopes
/**
* props.b does *not* influence `a`
*/
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
function Component(props) {
let x = [];
if (props.cond) {
@@ -30,7 +29,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(5);
let t53;
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
function Component(props) {
let x = [];
if (props.cond) {
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
import { makeArray } from "shared-runtime";
/**
@@ -51,7 +50,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
import { makeArray } from "shared-runtime";
/**
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
import { makeArray } from "shared-runtime";
/**
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
import { makeArray } from "shared-runtime";
function Component(props) {
@@ -42,7 +41,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
import { makeArray } from "shared-runtime";
function Component(props) {
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
import { makeArray } from "shared-runtime";
function Component(props) {
@@ -2,6 +2,7 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes:false
function Component(props) {
let x = [];
if (props.cond) {
@@ -24,7 +25,7 @@ export const FIXTURE_ENTRYPOINT = {
## Error
```
[ReactForget] Todo: Support early return within a reactive scope (6:6)
[ReactForget] Todo: Support early return within a reactive scope (7:7)
```
@@ -1,3 +1,4 @@
// @enableEarlyReturnInReactiveScopes:false
function Component(props) {
let x = [];
if (props.cond) {
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
function Component(props) {
let x = [];
let y = null;
@@ -29,7 +28,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = useMemoCache(4);
let y;
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
function Component(props) {
let x = [];
let y = null;
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
const { throwInput } = require("shared-runtime");
function Component(props) {
@@ -27,7 +26,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
const { throwInput } = require("shared-runtime");
function Component(props) {
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
const { throwInput } = require("shared-runtime");
function Component(props) {
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
const { throwInput } = require("shared-runtime");
function Component(props) {
@@ -28,7 +27,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
const { throwInput } = require("shared-runtime");
function Component(props) {
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
const { throwInput } = require("shared-runtime");
function Component(props) {
@@ -2,7 +2,6 @@
## Input
```javascript
// @enableEarlyReturnInReactiveScopes
const { shallowCopy, throwInput } = require("shared-runtime");
function Component(props) {
@@ -29,7 +28,7 @@ export const FIXTURE_ENTRYPOINT = {
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
import { unstable_useMemoCache as useMemoCache } from "react";
const { shallowCopy, throwInput } = require("shared-runtime");
function Component(props) {
@@ -1,4 +1,3 @@
// @enableEarlyReturnInReactiveScopes
const { shallowCopy, throwInput } = require("shared-runtime");
function Component(props) {