;
+ $[5] = t5;
+ $[6] = t6;
+ } else {
+ t6 = $[6];
+ }
+ return t6;
}
export const FIXTURE_ENTRYPOINT = {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/dont-merge-if-dep-is-inner-declaration-of-previous-scope.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/dont-merge-if-dep-is-inner-declaration-of-previous-scope.expect.md
index e8b5b351dd..ad843e230f 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/dont-merge-if-dep-is-inner-declaration-of-previous-scope.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/dont-merge-if-dep-is-inner-declaration-of-previous-scope.expect.md
@@ -99,41 +99,41 @@ function Component(t0) {
t2 = $[12];
}
let t3;
- if ($[13] !== a || $[14] !== b) {
- t3 = [a, b];
- $[13] = a;
- $[14] = b;
+ if ($[13] !== t2 || $[14] !== x) {
+ t3 = ;
+ $[13] = t2;
+ $[14] = x;
$[15] = t3;
} else {
t3 = $[15];
}
let t4;
- if ($[16] !== t2 || $[17] !== x) {
- t4 = ;
- $[16] = t2;
- $[17] = x;
+ if ($[16] !== a || $[17] !== b) {
+ t4 = [a, b];
+ $[16] = a;
+ $[17] = b;
$[18] = t4;
} else {
t4 = $[18];
}
let t5;
- if ($[19] !== t3 || $[20] !== z) {
- t5 = ;
- $[19] = t3;
+ if ($[19] !== t4 || $[20] !== z) {
+ t5 = ;
+ $[19] = t4;
$[20] = z;
$[21] = t5;
} else {
t5 = $[21];
}
let t6;
- if ($[22] !== t4 || $[23] !== t5) {
+ if ($[22] !== t3 || $[23] !== t5) {
t6 = (
<>
- {t4}
+ {t3}
{t5}
>
);
- $[22] = t4;
+ $[22] = t3;
$[23] = t5;
$[24] = t6;
} else {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.bug-repro-trycatch-nested-overlapping-range.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.bug-repro-trycatch-nested-overlapping-range.expect.md
index 2390842e78..ca77829e2f 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.bug-repro-trycatch-nested-overlapping-range.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.bug-repro-trycatch-nested-overlapping-range.expect.md
@@ -20,7 +20,7 @@ function Foo() {
## Error
```
-Invariant: Invalid nesting in program blocks or scopes. Items overlap but are not nested: 2:23(17:25)
+Invariant: Invalid nesting in program blocks or scopes. Items overlap but are not nested: 2:24(18:26)
```
\ No newline at end of file
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.repro-bug-ref-mutable-range.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.repro-bug-ref-mutable-range.expect.md
index 51b71b3136..7cd2acc9af 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.repro-bug-ref-mutable-range.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.repro-bug-ref-mutable-range.expect.md
@@ -21,7 +21,7 @@ function Foo(props, ref) {
## Error
```
-Invariant: Invalid nesting in program blocks or scopes. Items overlap but are not nested: 1:20(16:23)
+Invariant: Invalid nesting in program blocks or scopes. Items overlap but are not nested: 1:21(16:23)
```
\ No newline at end of file
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-reactive-scope-overlaps-try.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-reactive-scope-overlaps-try.expect.md
index e10a451cf3..95cdbe5aee 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-reactive-scope-overlaps-try.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.todo-reactive-scope-overlaps-try.expect.md
@@ -30,7 +30,7 @@ export const FIXTURE_ENTRYPOINT = {
## Error
```
-Invariant: Invalid nesting in program blocks or scopes. Items overlap but are not nested: 3:17(4:20)
+Invariant: Invalid nesting in program blocks or scopes. Items overlap but are not nested: 4:19(5:22)
```
\ No newline at end of file
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbtparam-with-jsx-element-content.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbtparam-with-jsx-element-content.expect.md
index df4964f43c..387031fc18 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbtparam-with-jsx-element-content.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbtparam-with-jsx-element-content.expect.md
@@ -32,7 +32,7 @@ function Component(t0) {
const $ = _c(4);
const { name, data, icon } = t0;
let t1;
- if ($[0] !== name || $[1] !== data || $[2] !== icon) {
+ if ($[0] !== name || $[1] !== icon || $[2] !== data) {
t1 = (
{fbt._(
@@ -62,8 +62,8 @@ function Component(t0) {
);
$[0] = name;
- $[1] = data;
- $[2] = icon;
+ $[1] = icon;
+ $[2] = data;
$[3] = t1;
} else {
t1 = $[3];
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/lambda-with-fbt.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/lambda-with-fbt.expect.md
index f7e71f4be7..5ac0ad17a0 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/lambda-with-fbt.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/lambda-with-fbt.expect.md
@@ -42,10 +42,10 @@ import { c as _c } from "react/compiler-runtime";
import { fbt } from "fbt";
function Component() {
- const $ = _c(1);
+ const $ = _c(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
- const buttonLabel = () => {
+ t0 = () => {
if (!someCondition) {
return fbt._("Purchase as a gift", null, { hk: "1gHj4g" });
} else {
@@ -66,17 +66,23 @@ function Component() {
}
}
};
-
- t0 = (
-
-
-
- );
$[0] = t0;
} else {
t0 = $[0];
}
- return t0;
+ const buttonLabel = t0;
+ let t1;
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
+ t1 = (
+
+
+
+ );
+ $[1] = t1;
+ } else {
+ t1 = $[1];
+ }
+ return t1;
}
```
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-of-nonmutating-loop-local-collection.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-of-nonmutating-loop-local-collection.expect.md
index 95f4036511..1c223a50f4 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-of-nonmutating-loop-local-collection.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/for-of-nonmutating-loop-local-collection.expect.md
@@ -82,41 +82,41 @@ function Component(t0) {
t4 = $[6];
}
let t5;
- if ($[7] !== x || $[8] !== b) {
- t5 = [x, b];
- $[7] = x;
- $[8] = b;
+ if ($[7] !== t4 || $[8] !== x) {
+ t5 = ;
+ $[7] = t4;
+ $[8] = x;
$[9] = t5;
} else {
t5 = $[9];
}
let t6;
- if ($[10] !== t4 || $[11] !== x) {
- t6 = ;
- $[10] = t4;
- $[11] = x;
+ if ($[10] !== x || $[11] !== b) {
+ t6 = [x, b];
+ $[10] = x;
+ $[11] = b;
$[12] = t6;
} else {
t6 = $[12];
}
let t7;
- if ($[13] !== t5 || $[14] !== y) {
- t7 = ;
- $[13] = t5;
+ if ($[13] !== t6 || $[14] !== y) {
+ t7 = ;
+ $[13] = t6;
$[14] = y;
$[15] = t7;
} else {
t7 = $[15];
}
let t8;
- if ($[16] !== t6 || $[17] !== t7) {
+ if ($[16] !== t5 || $[17] !== t7) {
t8 = (
<>
- {t6}
+ {t5}
{t7}
>
);
- $[16] = t6;
+ $[16] = t5;
$[17] = t7;
$[18] = t8;
} else {
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
index 7e4d44e752..becc4066e7 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md
@@ -24,42 +24,69 @@ function Component(props) {
```javascript
import { c as _c } from "react/compiler-runtime";
function Component(props) {
- const $ = _c(5);
+ const $ = _c(15);
const item = useFragment(FRAGMENT, props.item);
useFreeze(item);
let t0;
+ let T0;
+ let t1;
+ let T1;
if ($[0] !== item) {
const count = new MaybeMutable(item);
+ T1 = View;
+ T0 = View;
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
+ t1 = Text;
+ $[5] = t1;
+ } else {
+ t1 = $[5];
+ }
t0 = maybeMutate(count);
$[0] = item;
$[1] = t0;
+ $[2] = T0;
+ $[3] = t1;
+ $[4] = T1;
} else {
t0 = $[1];
- }
- let t1;
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
- t1 = Text;
- $[2] = t1;
- } else {
- t1 = $[2];
+ T0 = $[2];
+ t1 = $[3];
+ T1 = $[4];
}
let t2;
- if ($[3] !== t0) {
- t2 = (
-
-
- {t1}
- {t0}
-
-
- );
- $[3] = t0;
- $[4] = t2;
+ if ($[6] !== t0) {
+ t2 = {t0};
+ $[6] = t0;
+ $[7] = t2;
} else {
- t2 = $[4];
+ t2 = $[7];
}
- return t2;
+ let t3;
+ if ($[8] !== T0 || $[9] !== t1 || $[10] !== t2) {
+ t3 = (
+
+ {t1}
+ {t2}
+
+ );
+ $[8] = T0;
+ $[9] = t1;
+ $[10] = t2;
+ $[11] = t3;
+ } else {
+ t3 = $[11];
+ }
+ let t4;
+ if ($[12] !== T1 || $[13] !== t3) {
+ t4 = {t3};
+ $[12] = T1;
+ $[13] = t3;
+ $[14] = t4;
+ } else {
+ t4 = $[14];
+ }
+ return t4;
}
```
diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-whitespace.expect.md b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-whitespace.expect.md
index 063ffb548b..b9f791ed8b 100644
--- a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-whitespace.expect.md
+++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-whitespace.expect.md
@@ -36,29 +36,39 @@ import { c as _c } from "react/compiler-runtime";
import { StaticText1 } from "shared-runtime";
function Component() {
- const $ = _c(1);
+ const $ = _c(3);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
- t0 = (
+ t0 = ;
+ $[0] = t0;
+ } else {
+ t0 = $[0];
+ }
+ let t1;
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
+ t1 = ;
+ $[1] = t1;
+ } else {
+ t1 = $[1];
+ }
+ let t2;
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
+ t2 = (
- Before text
-
- Middle text
+ Before text{t0}Middle text
- Inner before text
-
- Inner middle text
+ Inner before text{t1}Inner middle text
Inner after text
After text