diff --git a/compiler/packages/babel-plugin-react-forget/src/Inference/InlineImmediatelyInvokedFunctionExpressions.ts b/compiler/packages/babel-plugin-react-forget/src/Inference/InlineImmediatelyInvokedFunctionExpressions.ts index 607c2430cc..7c654b82e1 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Inference/InlineImmediatelyInvokedFunctionExpressions.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Inference/InlineImmediatelyInvokedFunctionExpressions.ts @@ -295,5 +295,5 @@ function declareTemporary( } function promoteTemporary(temp: Identifier): void { - temp.name = `t${temp.id}`; + temp.name = `#t${temp.id}`; } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/ExtractScopeDeclarationsFromDestructuring.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/ExtractScopeDeclarationsFromDestructuring.ts index 7bcd3d3c06..7341cc5f22 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/ExtractScopeDeclarationsFromDestructuring.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/ExtractScopeDeclarationsFromDestructuring.ts @@ -152,7 +152,7 @@ function transformDestructuring( const tempId = state.env.nextIdentifierId; const temporary = { ...place, - identifier: { ...place.identifier, id: tempId, name: `t${tempId}` }, + identifier: { ...place.identifier, id: tempId, name: `#t${tempId}` }, }; renamed.set(place, temporary); return temporary; diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PromoteUsedTemporaries.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PromoteUsedTemporaries.ts index 1df0cd6d67..319bf7f930 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PromoteUsedTemporaries.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PromoteUsedTemporaries.ts @@ -85,8 +85,8 @@ function promoteTemporary(identifier: Identifier, state: VisitorState): void { suggestions: null, }); if (state.tags.has(identifier.id)) { - identifier.name = `T${state.nextId++}`; + identifier.name = `#T${state.nextId++}`; } else { - identifier.name = `t${state.nextId++}`; + identifier.name = `#t${state.nextId++}`; } } diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateEarlyReturns.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateEarlyReturns.ts index 6854593da9..609df8fb57 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateEarlyReturns.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/PropagateEarlyReturns.ts @@ -274,7 +274,7 @@ class Transform extends ReactiveFunctionTransform { earlyReturnValue = state.earlyReturnValue; } else { const identifier = createTemporaryPlace(this.env).identifier; - identifier.name = `t${identifier.id}`; + identifier.name = `#t${identifier.id}`; earlyReturnValue = { label: this.env.nextBlockId, loc, diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/RenameVariables.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/RenameVariables.ts index 22e6c7fd0e..5cf68659a0 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/RenameVariables.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/RenameVariables.ts @@ -13,26 +13,38 @@ import { Place, ReactiveBlock, ReactiveFunction, - ReactiveInstruction, ReactiveScopeBlock, } from "../HIR/HIR"; -import { eachInstructionLValue } from "../HIR/visitors"; -import { - ReactiveFunctionVisitor, - eachReactiveValueOperand, - visitReactiveFunction, -} from "./visitors"; +import { ReactiveFunctionVisitor, visitReactiveFunction } from "./visitors"; -/* +/** * Ensures that each named variable in the given function has a unique name * that does not conflict with any other variables in the same block scope. * Note that the scoping is based on the final inferred blocks, not the * block scopes that were present in the original source. Thus variables * that shadowed in the original source may end up with unique names in the * output, if Forget would merge those two blocks into a single scope. + * + * Variables are renamed using their original name followed by a number, + * starting with 0 and incrementing until a unique name is found. Eg if the + * compiler collapses three scopes that each had their own `foo` declaration, + * they will be renamed to `foo`, `foo0`, and `foo1`, assuming that no conflicts' + * exist for `foo0` and `foo1`. + * + * For temporary values that are promoted to named variables, the starting name + * is "T0" for values that appear in JSX tag position and "t0" otherwise. If this + * name conflicts, the number portion increments until the name is unique (t1, t2, etc). */ export function renameVariables(fn: ReactiveFunction): void { const scopes = new Scopes(); + renameVariablesImpl(fn, new Visitor(), scopes); +} + +function renameVariablesImpl( + fn: ReactiveFunction, + visitor: Visitor, + scopes: Scopes +): void { scopes.enter(() => { for (const param of fn.params) { if (param.kind === "Identifier") { @@ -41,11 +53,14 @@ export function renameVariables(fn: ReactiveFunction): void { scopes.visit(param.place.identifier); } } - visitReactiveFunction(fn, new Visitor(), scopes); + visitReactiveFunction(fn, visitor, scopes); }); } class Visitor extends ReactiveFunctionVisitor { + override visitLValue(_id: InstructionId, lvalue: Place, state: Scopes): void { + state.visit(lvalue.identifier); + } override visitPlace(id: InstructionId, place: Place, state: Scopes): void { state.visit(place.identifier); } @@ -54,40 +69,58 @@ class Visitor extends ReactiveFunctionVisitor { this.traverseBlock(block, state); }); } - override visitInstruction(instr: ReactiveInstruction, state: Scopes): void { - for (const operand of eachReactiveValueOperand(instr.value)) { - state.visit(operand.identifier); - } - for (const operand of eachInstructionLValue(instr)) { - this.visitPlace(instr.id, operand, state); - } - } + override visitScope(scope: ReactiveScopeBlock, state: Scopes): void { - /* - * Intentionally bypass visitBlock() since scopes do not introduce a new - * block scope - */ - this.traverseBlock(scope.instructions, state); + for (const [_, declaration] of scope.scope.declarations) { + state.visit(declaration.identifier); + } + this.traverseScope(scope, state); + } + + override visitReactiveFunctionValue( + _id: InstructionId, + _dependencies: Place[], + _fn: ReactiveFunction, + _state: Scopes + ): void { + renameVariablesImpl(_fn, this, _state); } } class Scopes { - #nextId: number = 0; - #seen: Set = new Set(); + #seen: Map = new Map(); #stack: Array> = [new Map()]; visit(identifier: Identifier): void { - if (identifier.name === null || this.#seen.has(identifier.id)) { + const originalName = identifier.name; + if (originalName === null) { return; } - this.#seen.add(identifier.id); - let name = identifier.name; + const mappedName = this.#seen.get(identifier.id); + if (mappedName !== undefined) { + identifier.name = mappedName; + return; + } + let name = originalName; + let id = 0; + if (name.startsWith("#t")) { + name = `t${id++}`; + } else if (name.startsWith("#T")) { + name = `T${id++}`; + } let previous = this.#lookup(name); while (previous !== null) { - name = `${identifier.name}$${this.#nextId++}`; + if (originalName.startsWith("#t")) { + name = `t${id++}`; + } else if (originalName.startsWith("#T")) { + name = `T${id++}`; + } else { + name = `${identifier.name}$${id++}`; + } previous = this.#lookup(name); } identifier.name = name; + this.#seen.set(identifier.id, name); this.#stack.at(-1)!.set(name, identifier.id); } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md index d321e844b3..394362a11c 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md @@ -49,16 +49,16 @@ function AllocatingPrimitiveAsDepNested(props) { x = $[2]; y = $[3]; } - let t2; + let t0; if ($[6] !== x || $[7] !== y) { - t2 = [x, y]; + t0 = [x, y]; $[6] = x; $[7] = y; - $[8] = t2; + $[8] = t0; } else { - t2 = $[8]; + t0 = $[8]; } - return t2; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md index 888a795075..24f090a26b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md @@ -50,16 +50,16 @@ function foo(a, b, c) { x = $[3]; z = $[4]; } - let t1; + let t0; if ($[7] !== x || $[8] !== z) { - t1 = [x, z]; + t0 = [x, z]; $[7] = x; $[8] = z; - $[9] = t1; + $[9] = t0; } else { - t1 = $[9]; + t0 = $[9]; } - return t1; + return t0; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md index e551b5d439..c7af0e05ff 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md @@ -40,24 +40,24 @@ function ArrayAtTest(props) { t1 = $[3]; } const arr = t1; - let t3; + let t2; if ($[4] !== props.y || $[5] !== arr) { - let t2; + let t3; if ($[7] !== props.y) { - t2 = bar(props.y); + t3 = bar(props.y); $[7] = props.y; - $[8] = t2; + $[8] = t3; } else { - t2 = $[8]; + t3 = $[8]; } - t3 = arr.at(t2); + t2 = arr.at(t3); $[4] = props.y; $[5] = arr; - $[6] = t3; + $[6] = t2; } else { - t3 = $[6]; + t2 = $[6]; } - const result = t3; + const result = t2; return result; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md index 09414c0d66..31a06dd6ce 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md @@ -32,51 +32,51 @@ import { function Component(props) { const $ = useMemoCache(4); const [x] = useState(0); - let t15; let t0; - if ($[0] !== x) { - t0 = calculateExpensiveNumber(x); - $[0] = x; - $[1] = t0; - } else { - t0 = $[1]; - } - t15 = t0; - const expensiveNumber = t15; let t1; - if ($[2] !== expensiveNumber) { - t1 =
{expensiveNumber}
; - $[2] = expensiveNumber; - $[3] = t1; + if ($[0] !== x) { + t1 = calculateExpensiveNumber(x); + $[0] = x; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - return t1; + t0 = t1; + const expensiveNumber = t0; + let t2; + if ($[2] !== expensiveNumber) { + t2 =
{expensiveNumber}
; + $[2] = expensiveNumber; + $[3] = t2; + } else { + t2 = $[3]; + } + return t2; } function Component2(props) { const $ = useMemoCache(4); const [x] = useState(0); - let t15; let t0; - if ($[0] !== x) { - t0 = calculateExpensiveNumber(x); - $[0] = x; - $[1] = t0; - } else { - t0 = $[1]; - } - t15 = t0; - const expensiveNumber = t15; let t1; - if ($[2] !== expensiveNumber) { - t1 =
{expensiveNumber}
; - $[2] = expensiveNumber; - $[3] = t1; + if ($[0] !== x) { + t1 = calculateExpensiveNumber(x); + $[0] = x; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - return t1; + t0 = t1; + const expensiveNumber = t0; + let t2; + if ($[2] !== expensiveNumber) { + t2 =
{expensiveNumber}
; + $[2] = expensiveNumber; + $[3] = t2; + } else { + t2 = $[3]; + } + return t2; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-kitchensink-import.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-kitchensink-import.expect.md index 33034d1768..165b04b81e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-kitchensink-import.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-kitchensink-import.expect.md @@ -34,51 +34,51 @@ import { function Component(props) { const $ = useMemoCache(4); const [x] = useState(0); - let t15; let t0; - if ($[0] !== x) { - t0 = calculateExpensiveNumber(x); - $[0] = x; - $[1] = t0; - } else { - t0 = $[1]; - } - t15 = t0; - const expensiveNumber = t15; let t1; - if ($[2] !== expensiveNumber) { - t1 =
{expensiveNumber}
; - $[2] = expensiveNumber; - $[3] = t1; + if ($[0] !== x) { + t1 = calculateExpensiveNumber(x); + $[0] = x; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - return t1; + t0 = t1; + const expensiveNumber = t0; + let t2; + if ($[2] !== expensiveNumber) { + t2 =
{expensiveNumber}
; + $[2] = expensiveNumber; + $[3] = t2; + } else { + t2 = $[3]; + } + return t2; } function Component2(props) { const $ = useMemoCache(4); const [x] = useState(0); - let t15; let t0; - if ($[0] !== x) { - t0 = calculateExpensiveNumber(x); - $[0] = x; - $[1] = t0; - } else { - t0 = $[1]; - } - t15 = t0; - const expensiveNumber = t15; let t1; - if ($[2] !== expensiveNumber) { - t1 =
{expensiveNumber}
; - $[2] = expensiveNumber; - $[3] = t1; + if ($[0] !== x) { + t1 = calculateExpensiveNumber(x); + $[0] = x; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - return t1; + t0 = t1; + const expensiveNumber = t0; + let t2; + if ($[2] !== expensiveNumber) { + t2 =
{expensiveNumber}
; + $[2] = expensiveNumber; + $[3] = t2; + } else { + t2 = $[3]; + } + return t2; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md index 60d08f81ea..2029e93686 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md @@ -29,26 +29,26 @@ import { calculateExpensiveNumber } from "shared-runtime"; function Component(props) { const $ = useMemoCache(4); const [x] = React.useState(0); - let t17; let t0; - if ($[0] !== x) { - t0 = calculateExpensiveNumber(x); - $[0] = x; - $[1] = t0; - } else { - t0 = $[1]; - } - t17 = t0; - const expensiveNumber = t17; let t1; - if ($[2] !== expensiveNumber) { - t1 =
{expensiveNumber}
; - $[2] = expensiveNumber; - $[3] = t1; + if ($[0] !== x) { + t1 = calculateExpensiveNumber(x); + $[0] = x; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - return t1; + t0 = t1; + const expensiveNumber = t0; + let t2; + if ($[2] !== expensiveNumber) { + t2 =
{expensiveNumber}
; + $[2] = expensiveNumber; + $[3] = t2; + } else { + t2 = $[3]; + } + return t2; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/block-scoping-switch-variable-scoping.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/block-scoping-switch-variable-scoping.expect.md index 6b77b6bf00..afa30b2e92 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/block-scoping-switch-variable-scoping.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/block-scoping-switch-variable-scoping.expect.md @@ -34,16 +34,16 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(2); - let t22; let t0; + let t1; if ($[0] !== props.value) { - t0 = { value: props.value }; + t1 = { value: props.value }; $[0] = props.value; - $[1] = t0; + $[1] = t1; } else { - t0 = $[1]; + t1 = $[1]; } - const handlers = t0; + const handlers = t1; bb2: switch (props.test) { case true: { console.log(handlers.value); @@ -53,8 +53,8 @@ function Component(props) { } } - t22 = handlers; - const outerHandlers = t22; + t0 = handlers; + const outerHandlers = t0; return outerHandlers; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md index c65dc3cef7..7231221e31 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/bug.useMemo-deps-array-not-cleared.expect.md @@ -29,17 +29,17 @@ function App(t25) { const { text, hasDeps } = t25; hasDeps ? null : [text]; - let t18; let t0; + let t1; if ($[0] !== text) { - t0 = text.toUpperCase(); + t1 = text.toUpperCase(); $[0] = text; - $[1] = t0; + $[1] = t1; } else { - t0 = $[1]; + t1 = $[1]; } - t18 = t0; - const resolvedText = t18; + t0 = t1; + const resolvedText = t0; return resolvedText; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md index 052b76f042..2107913315 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md @@ -20,28 +20,28 @@ function Component(props) { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(4); - let t1; + let t0; if ($[0] !== props) { const x = makeFunction(props); - let t0; + let t1; if ($[2] !== props.text) { - t0 = ( + t1 = (
{props.text}
); $[2] = props.text; - $[3] = t0; + $[3] = t1; } else { - t0 = $[3]; + t1 = $[3]; } - t1 = x(t0); + t0 = x(t1); $[0] = props; - $[1] = t1; + $[1] = t0; } else { - t1 = $[1]; + t0 = $[1]; } - const y = t1; + const y = t0; return y; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-early-return.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-early-return.expect.md index 29074d3508..41f5bc32cc 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-early-return.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/conditional-early-return.expect.md @@ -73,14 +73,14 @@ import { unstable_useMemoCache as useMemoCache } from "react"; function ComponentA(props) { const $ = useMemoCache(5); let a_DEBUG; - let t37; + let t0; if ($[0] !== props.a || $[1] !== props.b || $[2] !== props.d) { - t37 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb7: { a_DEBUG = []; a_DEBUG.push(props.a); if (props.b) { - t37 = null; + t0 = null; break bb7; } @@ -90,13 +90,13 @@ function ComponentA(props) { $[1] = props.b; $[2] = props.d; $[3] = a_DEBUG; - $[4] = t37; + $[4] = t0; } else { a_DEBUG = $[3]; - t37 = $[4]; + t0 = $[4]; } - if (t37 !== Symbol.for("react.early_return_sentinel")) { - return t37; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } return a_DEBUG; } @@ -129,15 +129,15 @@ function ComponentB(props) { function ComponentC(props) { const $ = useMemoCache(3); let a; - let t47; + let t0; if ($[0] !== props) { - t47 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb7: { a = []; a.push(props.a); if (props.b) { a.push(props.c); - t47 = null; + t0 = null; break bb7; } @@ -145,13 +145,13 @@ function ComponentC(props) { } $[0] = props; $[1] = a; - $[2] = t47; + $[2] = t0; } else { a = $[1]; - t47 = $[2]; + t0 = $[2]; } - if (t47 !== Symbol.for("react.early_return_sentinel")) { - return t47; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } return a; } @@ -162,15 +162,15 @@ function ComponentC(props) { function ComponentD(props) { const $ = useMemoCache(3); let a; - let t47; + let t0; if ($[0] !== props) { - t47 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb7: { a = []; a.push(props.a); if (props.b) { a.push(props.c); - t47 = a; + t0 = a; break bb7; } @@ -178,13 +178,13 @@ function ComponentD(props) { } $[0] = props; $[1] = a; - $[2] = t47; + $[2] = t0; } else { a = $[1]; - t47 = $[2]; + t0 = $[2]; } - if (t47 !== Symbol.for("react.early_return_sentinel")) { - return t47; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } return a; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/createElement-freeze.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/createElement-freeze.expect.md index 158edcf8ad..80594b8137 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/createElement-freeze.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/createElement-freeze.expect.md @@ -37,22 +37,22 @@ function Component(props) { t0 = $[1]; } const childProps = t0; - let t2; + let t1; if ($[2] !== childProps) { - let t1; + let t2; if ($[4] === Symbol.for("react.memo_cache_sentinel")) { - t1 = ["hello world"]; - $[4] = t1; + t2 = ["hello world"]; + $[4] = t2; } else { - t1 = $[4]; + t2 = $[4]; } - t2 = React.createElement("div", childProps, t1); + t1 = React.createElement("div", childProps, t2); $[2] = childProps; - $[3] = t2; + $[3] = t1; } else { - t2 = $[3]; + t1 = $[3]; } - const element = t2; + const element = t1; shallowCopy(childProps); return element; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md index 2deccae240..60b8b74221 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-and-local-variables-with-default.expect.md @@ -64,29 +64,29 @@ function Component(props) { if ($[0] !== post) { allUrls = []; - const { media: t0, comments: t2, urls: t4 } = post; - let t1; - if ($[4] !== t0) { - t1 = t0 === undefined ? null : t0; - $[4] = t0; - $[5] = t1; - } else { - t1 = $[5]; - } - media = t1; + const { media: t0, comments: t1, urls: t2 } = post; let t3; - if ($[6] !== t2) { - t3 = t2 === undefined ? [] : t2; - $[6] = t2; - $[7] = t3; + if ($[4] !== t0) { + t3 = t0 === undefined ? null : t0; + $[4] = t0; + $[5] = t3; } else { - t3 = $[7]; + t3 = $[5]; } - const comments = t3; + media = t3; + let t4; + if ($[6] !== t1) { + t4 = t1 === undefined ? [] : t1; + $[6] = t1; + $[7] = t4; + } else { + t4 = $[7]; + } + const comments = t4; let t5; - if ($[8] !== t4) { - t5 = t4 === undefined ? [] : t4; - $[8] = t4; + if ($[8] !== t2) { + t5 = t2 === undefined ? [] : t2; + $[8] = t2; $[9] = t5; } else { t5 = $[9]; @@ -118,17 +118,17 @@ function Component(props) { allUrls = $[2]; onClick = $[3]; } - let t7; + let t0; if ($[12] !== media || $[13] !== allUrls || $[14] !== onClick) { - t7 = ; + t0 = ; $[12] = media; $[13] = allUrls; $[14] = onClick; - $[15] = t7; + $[15] = t0; } else { - t7 = $[15]; + t0 = $[15]; } - return t7; + return t0; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md index 83f9bb28a8..e67b488bbd 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/destructuring-mixed-scope-declarations-and-locals.expect.md @@ -37,11 +37,11 @@ function Component(props) { if ($[0] !== post) { const allUrls = []; - const { media: t83, comments, urls } = post; - media = t83; - let t0; + const { media: t0, comments, urls } = post; + media = t0; + let t1; if ($[3] !== comments.length) { - t0 = (e) => { + t1 = (e) => { if (!comments.length) { return; } @@ -49,11 +49,11 @@ function Component(props) { console.log(comments.length); }; $[3] = comments.length; - $[4] = t0; + $[4] = t1; } else { - t0 = $[4]; + t1 = $[4]; } - onClick = t0; + onClick = t1; allUrls.push(...urls); $[0] = post; @@ -63,16 +63,16 @@ function Component(props) { media = $[1]; onClick = $[2]; } - let t1; + let t0; if ($[5] !== media || $[6] !== onClick) { - t1 = ; + t0 = ; $[5] = media; $[6] = onClick; - $[7] = t1; + $[7] = t0; } else { - t1 = $[7]; + t0 = $[7]; } - return t1; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usememo.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usememo.expect.md index 75c8dc41d5..9da6025aa0 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usememo.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/drop-methodcall-usememo.expect.md @@ -28,7 +28,7 @@ import * as React from "react"; function Component(props) { const $ = useMemoCache(2); - let t19; + let t0; let x; if ($[0] !== props.value) { x = []; @@ -38,8 +38,8 @@ function Component(props) { } else { x = $[1]; } - t19 = x; - const x_0 = t19; + t0 = x; + const x_0 = t0; return x_0; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-nested-early-return-within-reactive-scope.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-nested-early-return-within-reactive-scope.expect.md index 5a6ced61b7..4a55cb243e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-nested-early-return-within-reactive-scope.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-nested-early-return-within-reactive-scope.expect.md @@ -32,29 +32,29 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(5); - let t53; + let t0; if ($[0] !== props) { - t53 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb11: { const x = []; if (props.cond) { x.push(props.a); if (props.b) { - let t0; + let t1; if ($[2] !== props.b) { - t0 = [props.b]; + t1 = [props.b]; $[2] = props.b; - $[3] = t0; + $[3] = t1; } else { - t0 = $[3]; + t1 = $[3]; } - const y = t0; + const y = t1; x.push(y); - t53 = x; + t0 = x; break bb11; } - t53 = x; + t0 = x; break bb11; } else { let t1; @@ -64,17 +64,17 @@ function Component(props) { } else { t1 = $[4]; } - t53 = t1; + t0 = t1; break bb11; } } $[0] = props; - $[1] = t53; + $[1] = t0; } else { - t53 = $[1]; + t0 = $[1]; } - if (t53 !== Symbol.for("react.early_return_sentinel")) { - return t53; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.expect.md index 63df1742d0..50e4da268a 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.expect.md @@ -70,35 +70,35 @@ let ENABLE_FEATURE = false; function Component(props) { const $ = useMemoCache(3); - let t37; + let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t37 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb8: { const x = []; if (ENABLE_FEATURE) { x.push(42); - t37 = x; + t0 = x; break bb8; } else { console.log("fallthrough"); } } - $[0] = t37; + $[0] = t0; } else { - t37 = $[0]; + t0 = $[0]; } - if (t37 !== Symbol.for("react.early_return_sentinel")) { - return t37; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } - let t0; + let t1; if ($[1] !== props.a) { - t0 = makeArray(props.a); + t1 = makeArray(props.a); $[1] = props.a; - $[2] = t0; + $[2] = t1; } else { - t0 = $[2]; + t1 = $[2]; } - return t0; + return t1; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-within-reactive-scope.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-within-reactive-scope.expect.md index 1996b38494..30cdc84b95 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-within-reactive-scope.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/early-return-within-reactive-scope.expect.md @@ -46,35 +46,35 @@ import { makeArray } from "shared-runtime"; function Component(props) { const $ = useMemoCache(4); - let t33; + let t0; if ($[0] !== props) { - t33 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb8: { const x = []; if (props.cond) { x.push(props.a); - t33 = x; + t0 = x; break bb8; } else { - let t0; + let t1; if ($[2] !== props.b) { - t0 = makeArray(props.b); + t1 = makeArray(props.b); $[2] = props.b; - $[3] = t0; + $[3] = t1; } else { - t0 = $[3]; + t1 = $[3]; } - t33 = t0; + t0 = t1; break bb8; } } $[0] = props; - $[1] = t33; + $[1] = t0; } else { - t33 = $[1]; + t0 = $[1]; } - if (t33 !== Symbol.for("react.early_return_sentinel")) { - return t33; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md index b2167c3b55..87a4a736d7 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md @@ -26,8 +26,8 @@ function Component(props) { const $ = useMemoCache(7); let b; if ($[0] !== props.a) { - const { a, ...t29 } = props.a; - b = t29; + const { a, ...t0 } = props.a; + b = t0; $[0] = props.a; $[1] = b; } else { @@ -35,8 +35,8 @@ function Component(props) { } let d; if ($[2] !== props.c) { - const [c, ...t30] = props.c; - d = t30; + const [c, ...t0] = props.c; + d = t0; $[2] = props.c; $[3] = d; } else { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md index 8127d8dd93..b0e29c337d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/hooks-with-prefix.expect.md @@ -50,35 +50,35 @@ function Component() { const [state] = React$useState(0); const object = Internal$Reassigned$useHook(); const json = JSON.stringify(object); - let t25; let t0; - if ($[0] !== state) { - t25 = makeArray(state); - const doubledArray = t25; - - t0 = doubledArray.join(""); - $[0] = state; - $[1] = t0; - $[2] = t25; - } else { - t0 = $[1]; - t25 = $[2]; - } let t1; - if ($[3] !== t0 || $[4] !== json) { - t1 = ( + if ($[0] !== state) { + t0 = makeArray(state); + const doubledArray = t0; + + t1 = doubledArray.join(""); + $[0] = state; + $[1] = t1; + $[2] = t0; + } else { + t1 = $[1]; + t0 = $[2]; + } + let t2; + if ($[3] !== t1 || $[4] !== json) { + t2 = (
- {t0} + {t1} {json}
); - $[3] = t0; + $[3] = t1; $[4] = json; - $[5] = t1; + $[5] = t2; } else { - t1 = $[5]; + t2 = $[5]; } - return t1; + return t2; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-logical.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-logical.expect.md index fa418e1522..9d2ae0047e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-logical.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-logical.expect.md @@ -27,19 +27,19 @@ import { getNull } from "shared-runtime"; function Component(props) { const $ = useMemoCache(3); - let t10; + let t0; let items; if ($[0] !== props.a) { - t10 = getNull() ?? []; - items = t10; + t0 = getNull() ?? []; + items = t0; items.push(props.a); $[0] = props.a; $[1] = items; - $[2] = t10; + $[2] = t0; } else { items = $[1]; - t10 = $[2]; + t0 = $[2]; } return items; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md index 8b1e2452ff..bb44b2a218 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later-phi.expect.md @@ -29,13 +29,13 @@ function Component(props) { const $ = useMemoCache(2); let items; if ($[0] !== props) { - let t9; + let t0; if (props.cond) { - t9 = []; + t0 = []; } else { - t9 = null; + t0 = null; } - items = t9; + items = t0; items?.push(props.a); $[0] = props; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later.expect.md index 95abbbdfc1..dcfe2856be 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/iife-return-modified-later.expect.md @@ -23,19 +23,19 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(3); - let t4; + let t0; let items; if ($[0] !== props.a) { - t4 = []; - items = t4; + t0 = []; + items = t0; items.push(props.a); $[0] = props.a; $[1] = items; - $[2] = t4; + $[2] = t0; } else { items = $[1]; - t4 = $[2]; + t0 = $[2]; } return items; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md index 97c6f6bae5..017ce9eb92 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md @@ -27,66 +27,66 @@ function Component(props) { const $ = useMemoCache(15); const item = useFragment(FRAGMENT, props.item); useFreeze(item); - let t1; - let T2; let t0; - let T3; + let T0; + let t1; + let T1; if ($[0] !== item) { const count = new MaybeMutable(item); - T3 = View; - T2 = View; + T1 = View; + T0 = View; if ($[5] === Symbol.for("react.memo_cache_sentinel")) { - t0 = Text; - $[5] = t0; + t1 = Text; + $[5] = t1; } else { - t0 = $[5]; + t1 = $[5]; } - t1 = maybeMutate(count); + t0 = maybeMutate(count); $[0] = item; - $[1] = t1; - $[2] = T2; - $[3] = t0; - $[4] = T3; + $[1] = t0; + $[2] = T0; + $[3] = t1; + $[4] = T1; } else { - t1 = $[1]; - T2 = $[2]; - t0 = $[3]; - T3 = $[4]; + t0 = $[1]; + T0 = $[2]; + t1 = $[3]; + T1 = $[4]; + } + let t2; + if ($[6] !== t0) { + t2 = {t0}; + $[6] = t0; + $[7] = t2; + } else { + t2 = $[7]; + } + 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 ($[6] !== t1) { - t4 = {t1}; - $[6] = t1; - $[7] = t4; + if ($[12] !== T1 || $[13] !== t3) { + t4 = {t3}; + $[12] = T1; + $[13] = t3; + $[14] = t4; } else { - t4 = $[7]; + t4 = $[14]; } - let t5; - if ($[8] !== T2 || $[9] !== t0 || $[10] !== t4) { - t5 = ( - - {t0} - {t4} - - ); - $[8] = T2; - $[9] = t0; - $[10] = t4; - $[11] = t5; - } else { - t5 = $[11]; - } - let t6; - if ($[12] !== T3 || $[13] !== t5) { - t6 = {t5}; - $[12] = T3; - $[13] = t5; - $[14] = t6; - } else { - t6 = $[14]; - } - return t6; + return t4; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md index 7c435203c0..50bf79555d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md @@ -55,47 +55,47 @@ function Component(props) { const $ = useMemoCache(11); let Tag; let T0; - let t1; + let t0; if ($[0] !== props.component || $[1] !== props.alternateComponent) { const maybeMutable = new MaybeMutable(); Tag = props.component; T0 = Tag; - t1 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable)); + t0 = ((Tag = props.alternateComponent), maybeMutate(maybeMutable)); $[0] = props.component; $[1] = props.alternateComponent; $[2] = Tag; $[3] = T0; - $[4] = t1; + $[4] = t0; } else { Tag = $[2]; T0 = $[3]; - t1 = $[4]; + t0 = $[4]; + } + let t1; + if ($[5] !== Tag) { + t1 = ; + $[5] = Tag; + $[6] = t1; + } else { + t1 = $[6]; } let t2; - if ($[5] !== Tag) { - t2 = ; - $[5] = Tag; - $[6] = t2; - } else { - t2 = $[6]; - } - let t3; - if ($[7] !== T0 || $[8] !== t1 || $[9] !== t2) { - t3 = ( + if ($[7] !== T0 || $[8] !== t0 || $[9] !== t1) { + t2 = ( + {t0} {t1} - {t2} ); $[7] = T0; - $[8] = t1; - $[9] = t2; - $[10] = t3; + $[8] = t0; + $[9] = t1; + $[10] = t2; } else { - t3 = $[10]; + t2 = $[10]; } - return t3; + return t2; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md index ae16f4eec0..c69870b3af 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md @@ -31,23 +31,23 @@ import { StaticText1, StaticText2 } from "shared-runtime"; function Component(props) { const $ = useMemoCache(3); - const t1 = props.value; - let t0; + const t0 = props.value; + let t1; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = ; - $[0] = t0; + t1 = ; + $[0] = t1; } else { - t0 = $[0]; + t1 = $[0]; } let t2; - if ($[1] !== t1) { + if ($[1] !== t0) { t2 = ( - {t1} {t0} + {t1} ); - $[1] = t1; + $[1] = t0; $[2] = t2; } else { t2 = $[2]; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-with-param-as-captured-dep.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-with-param-as-captured-dep.expect.md index 531c10b931..bfa76bf899 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-with-param-as-captured-dep.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/nested-function-with-param-as-captured-dep.expect.md @@ -25,19 +25,19 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; function Foo() { const $ = useMemoCache(1); - let t18; let t0; + let t1; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = function a(t28) { + t1 = function a(t28) { const x_0 = t28 === undefined ? () => {} : t28; return x_0; }; - $[0] = t0; + $[0] = t1; } else { - t0 = $[0]; + t1 = $[0]; } - t18 = t0; - return t18; + t0 = t1; + return t0; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/noAlias-filter-on-array-prop.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/noAlias-filter-on-array-prop.expect.md index 17b3897c8d..d00658ecaf 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/noAlias-filter-on-array-prop.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/noAlias-filter-on-array-prop.expect.md @@ -34,22 +34,22 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(3); - let t1; + let t0; if ($[0] !== props.items) { - let t0; + let t1; if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t0 = (item) => item != null; - $[2] = t0; + t1 = (item) => item != null; + $[2] = t1; } else { - t0 = $[2]; + t1 = $[2]; } - t1 = props.items.filter(t0); + t0 = props.items.filter(t1); $[0] = props.items; - $[1] = t1; + $[1] = t0; } else { - t1 = $[1]; + t0 = $[1]; } - const filtered = t1; + const filtered = t0; return filtered; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md index 9b3444a00a..94a7a9d196 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md @@ -33,15 +33,15 @@ function foo(a, b, c, d) { } x = t0; } else { - let t1; + let t0; if ($[2] !== c) { - t1 = { c }; + t0 = { c }; $[2] = c; - $[3] = t1; + $[3] = t0; } else { - t1 = $[3]; + t0 = $[3]; } - x = t1; + x = t0; } return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md index 552522e514..e595d3583b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/object-shorthand-method-2.expect.md @@ -38,31 +38,31 @@ function useHook(t16) { } else { t0 = $[1]; } - let t2; + let t1; if ($[2] !== b || $[3] !== c || $[4] !== t0) { - let t1; + let t2; if ($[6] !== c) { - t1 = { c }; + t2 = { c }; $[6] = c; - $[7] = t1; + $[7] = t2; } else { - t1 = $[7]; + t2 = $[7]; } - t2 = { + t1 = { x: t0, y() { return [b]; }, - z: t1, + z: t2, }; $[2] = b; $[3] = c; $[4] = t0; - $[5] = t2; + $[5] = t1; } else { - t2 = $[5]; + t1 = $[5]; } - return t2; + return t1; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/partial-early-return-within-reactive-scope.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/partial-early-return-within-reactive-scope.expect.md index c4f26fe8f7..b9b7a31440 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/partial-early-return-within-reactive-scope.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/partial-early-return-within-reactive-scope.expect.md @@ -32,39 +32,39 @@ import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(4); let y; - let t46; + let t0; if ($[0] !== props) { - t46 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb11: { const x = []; if (props.cond) { x.push(props.a); - t46 = x; + t0 = x; break bb11; } else { - let t0; + let t1; if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t0 = foo(); - $[3] = t0; + t1 = foo(); + $[3] = t1; } else { - t0 = $[3]; + t1 = $[3]; } - y = t0; + y = t1; if (props.b) { - t46 = undefined; + t0 = undefined; break bb11; } } } $[0] = props; $[1] = y; - $[2] = t46; + $[2] = t0; } else { y = $[1]; - t46 = $[2]; + t0 = $[2]; } - if (t46 !== Symbol.for("react.early_return_sentinel")) { - return t46; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } return y; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md index 9f834b9cf5..6ab32ad29d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md @@ -51,16 +51,16 @@ function PrimitiveAsDepNested(props) { x = $[2]; y = $[3]; } - let t2; + let t0; if ($[6] !== x || $[7] !== y) { - t2 = [x, y]; + t0 = [x, y]; $[6] = x; $[7] = y; - $[8] = t2; + $[8] = t0; } else { - t2 = $[8]; + t0 = $[8]; } - return t2; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md index 510cbcd93a..4180315a7a 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/readonly-object-method-calls.expect.md @@ -46,15 +46,15 @@ function Component(props) { } const count = posts.length; foo(count); - let t1; + let t0; if ($[3] !== posts) { - t1 = <>{posts}; + t0 = <>{posts}; $[3] = posts; - $[4] = t1; + $[4] = t0; } else { - t1 = $[4]; + t0 = $[4]; } - return t1; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md index ea814d9cf9..fe59fd025e 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md @@ -51,16 +51,16 @@ function Component(props) { x = $[3]; y = $[4]; } - let t1; + let t0; if ($[6] !== x || $[7] !== y) { - t1 = ; + t0 = ; $[6] = x; $[7] = y; - $[8] = t1; + $[8] = t0; } else { - t1 = $[8]; + t0 = $[8]; } - return t1; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment.expect.md index 72e6704a6b..a552e9d8fa 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/reassignment.expect.md @@ -47,16 +47,16 @@ function Component(props) { x = $[2]; y = $[3]; } - let t1; + let t0; if ($[5] !== x || $[6] !== y) { - t1 = ; + t0 = ; $[5] = x; $[6] = y; - $[7] = t1; + $[7] = t0; } else { - t1 = $[7]; + t0 = $[7]; } - return t1; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md index 8d84236c61..f8fe2bbda4 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md @@ -44,14 +44,14 @@ function Component(props) { } return t1; } - let t2; + let t1; if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t2 =
Default
; - $[3] = t2; + t1 =
Default
; + $[3] = t1; } else { - t2 = $[3]; + t1 = $[3]; } - return t2; + return t1; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.expect.md index ec757524f9..2d85dfc595 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/remove-memoization-kitchen-sink.expect.md @@ -28,11 +28,11 @@ function Component(props) { }; const object = { x, onChange }; - let t43; + let t0; const { x: x_0, onChange: onChange_0 } = object; - t43 = ; - return t43; + t0 = ; + return t0; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-dont-memoize-array-with-mutable-map-after-hook.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-dont-memoize-array-with-mutable-map-after-hook.expect.md index c869711dae..6119ee447d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-dont-memoize-array-with-mutable-map-after-hook.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-dont-memoize-array-with-mutable-map-after-hook.expect.md @@ -62,27 +62,27 @@ function Component(props) { let y; - const t3 = x.map((item) => { + const t2 = x.map((item) => { item.flag = true; return {item.text}; }); - let t2; + let t3; if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t2 = mutate(y); - $[2] = t2; + t3 = mutate(y); + $[2] = t3; } else { - t2 = $[2]; + t3 = $[2]; } let t4; - if ($[3] !== onClick || $[4] !== t3) { + if ($[3] !== onClick || $[4] !== t2) { t4 = (
- {t3} {t2} + {t3}
); $[3] = onClick; - $[4] = t3; + $[4] = t2; $[5] = t4; } else { t4 = $[5]; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-hoisting-variable-collision.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-hoisting-variable-collision.expect.md index b3f4a3f0c3..8ba29e178b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-hoisting-variable-collision.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-hoisting-variable-collision.expect.md @@ -21,31 +21,31 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(5); - let t1; + let t0; if ($[0] !== props.items) { - let t0; + let t1; if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t0 = (x) => x; - $[2] = t0; + t1 = (x) => x; + $[2] = t1; } else { - t0 = $[2]; + t1 = $[2]; } - t1 = props.items.map(t0); + t0 = props.items.map(t1); $[0] = props.items; - $[1] = t1; + $[1] = t0; } else { - t1 = $[1]; + t0 = $[1]; } - const items = t1; - let t2; + const items = t0; + let t1; if ($[3] !== items) { - t2 = [42, items]; + t1 = [42, items]; $[3] = items; - $[4] = t2; + $[4] = t1; } else { - t2 = $[4]; + t1 = $[4]; } - return t2; + return t1; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-reassign-to-variable-without-mutable-range.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-reassign-to-variable-without-mutable-range.expect.md index 7a271c5f3d..b32a35cb95 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-reassign-to-variable-without-mutable-range.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-reassign-to-variable-without-mutable-range.expect.md @@ -60,16 +60,16 @@ function Component(a, b) { x = $[4]; y = $[5]; } - let t3; + let t2; if ($[8] !== x || $[9] !== y) { - t3 = [x, y]; + t2 = [x, y]; $[8] = x; $[9] = y; - $[10] = t3; + $[10] = t2; } else { - t3 = $[10]; + t2 = $[10]; } - return t3; + return t2; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md index 202733de2c..43b3a00969 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-renaming-conflicting-decls.expect.md @@ -46,123 +46,123 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(29); - let t10; let t0; - let t92; + let t1; + let t2; if ($[0] !== props) { - t92 = Symbol.for("react.early_return_sentinel"); + t2 = Symbol.for("react.early_return_sentinel"); bb10: { - t10 = toJSON(props); - const propsString = t10; + t0 = toJSON(props); + const propsString = t0; if (propsString.length <= 2) { - t92 = null; + t2 = null; break bb10; } - t0 = identity(propsString); + t1 = identity(propsString); } $[0] = props; - $[1] = t0; - $[2] = t92; - $[3] = t10; + $[1] = t1; + $[2] = t2; + $[3] = t0; } else { - t0 = $[1]; - t92 = $[2]; - t10 = $[3]; + t1 = $[1]; + t2 = $[2]; + t0 = $[3]; } - if (t92 !== Symbol.for("react.early_return_sentinel")) { - return t92; + if (t2 !== Symbol.for("react.early_return_sentinel")) { + return t2; } - let t1; - if ($[4] !== t0) { - t1 = { url: t0 }; - $[4] = t0; - $[5] = t1; - } else { - t1 = $[5]; - } - const linkProps = t1; - let T7; - let t8; - let t2; let t3; + if ($[4] !== t1) { + t3 = { url: t1 }; + $[4] = t1; + $[5] = t3; + } else { + t3 = $[5]; + } + const linkProps = t3; + let T0; let t4; let t5; let t6; + let t7; + let t8; let t9; + let t10; if ($[6] !== linkProps) { const x = {}; - T7 = Stringify; - t8 = linkProps; + T0 = Stringify; + t4 = linkProps; if ($[15] === Symbol.for("react.memo_cache_sentinel")) { - t2 = [1]; - t3 = [2]; - t4 = [3]; - t5 = [4]; - t6 = [5]; - $[15] = t2; - $[16] = t3; - $[17] = t4; - $[18] = t5; - $[19] = t6; + t5 = [1]; + t6 = [2]; + t7 = [3]; + t8 = [4]; + t9 = [5]; + $[15] = t5; + $[16] = t6; + $[17] = t7; + $[18] = t8; + $[19] = t9; } else { - t2 = $[15]; - t3 = $[16]; - t4 = $[17]; - t5 = $[18]; - t6 = $[19]; + t5 = $[15]; + t6 = $[16]; + t7 = $[17]; + t8 = $[18]; + t9 = $[19]; } - t9 = makeArray(x, 2); + t10 = makeArray(x, 2); $[6] = linkProps; - $[7] = T7; - $[8] = t8; - $[9] = t2; - $[10] = t3; - $[11] = t4; - $[12] = t5; - $[13] = t6; - $[14] = t9; + $[7] = T0; + $[8] = t4; + $[9] = t5; + $[10] = t6; + $[11] = t7; + $[12] = t8; + $[13] = t9; + $[14] = t10; } else { - T7 = $[7]; - t8 = $[8]; - t2 = $[9]; - t3 = $[10]; - t4 = $[11]; - t5 = $[12]; - t6 = $[13]; - t9 = $[14]; + T0 = $[7]; + t4 = $[8]; + t5 = $[9]; + t6 = $[10]; + t7 = $[11]; + t8 = $[12]; + t9 = $[13]; + t10 = $[14]; } - let t10$0; + let t11; if ( - $[20] !== T7 || - $[21] !== t8 || - $[22] !== t2 || - $[23] !== t3 || - $[24] !== t4 || - $[25] !== t5 || - $[26] !== t6 || - $[27] !== t9 + $[20] !== T0 || + $[21] !== t4 || + $[22] !== t5 || + $[23] !== t6 || + $[24] !== t7 || + $[25] !== t8 || + $[26] !== t9 || + $[27] !== t10 ) { - t10$0 = ( - - {t9} - + t11 = ( + + {t10} + ); - $[20] = T7; - $[21] = t8; - $[22] = t2; - $[23] = t3; - $[24] = t4; - $[25] = t5; - $[26] = t6; - $[27] = t9; - $[28] = t10$0; + $[20] = T0; + $[21] = t4; + $[22] = t5; + $[23] = t6; + $[24] = t7; + $[25] = t8; + $[26] = t9; + $[27] = t10; + $[28] = t11; } else { - t10$0 = $[28]; + t11 = $[28]; } - return t10$0; + return t11; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md index 1db889796f..6cc2dbfca9 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/repro-undefined-expression-of-jsxexpressioncontainer.expect.md @@ -52,18 +52,18 @@ function Component(props) { const { buttons } = props; let nonPrimaryButtons; if ($[0] !== buttons) { - const [primaryButton, ...t79] = buttons; - nonPrimaryButtons = t79; + const [primaryButton, ...t0] = buttons; + nonPrimaryButtons = t0; $[0] = buttons; $[1] = nonPrimaryButtons; } else { nonPrimaryButtons = $[1]; } - let t1; + let t0; if ($[2] !== nonPrimaryButtons) { - let t0; + let t1; if ($[4] === Symbol.for("react.memo_cache_sentinel")) { - t0 = (buttonProps, i) => ( + t1 = (buttonProps, i) => ( ); - $[4] = t0; + $[4] = t1; } else { - t0 = $[4]; + t1 = $[4]; } - t1 = nonPrimaryButtons.map(t0); + t0 = nonPrimaryButtons.map(t1); $[2] = nonPrimaryButtons; - $[3] = t1; + $[3] = t0; } else { - t1 = $[3]; + t0 = $[3]; } - const renderedNonPrimaryButtons = t1; - let t2; + const renderedNonPrimaryButtons = t0; + let t1; if ($[5] !== renderedNonPrimaryButtons) { - t2 = {renderedNonPrimaryButtons}; + t1 = {renderedNonPrimaryButtons}; $[5] = renderedNonPrimaryButtons; - $[6] = t2; + $[6] = t1; } else { - t2 = $[6]; + t1 = $[6]; } - return t2; + return t1; } const styles = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md index 0224cf3662..a4d3dc6ac2 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-locals-named-like-hooks.expect.md @@ -51,20 +51,20 @@ function Component(props) { const y = useFeature; const z = useFeature.useProperty; - let t1; + let t0; if ($[1] === Symbol.for("react.memo_cache_sentinel")) { - t1 = ( + t0 = ( {x} {y} {z} ); - $[1] = t1; + $[1] = t0; } else { - t1 = $[1]; + t0 = $[1]; } - return t1; + return t0; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-props-named-like-hooks.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-props-named-like-hooks.expect.md index 58f24fe35f..e98597bc80 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-props-named-like-hooks.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/rules-of-hooks/allow-props-named-like-hooks.expect.md @@ -53,9 +53,9 @@ function Component(t29) { const y = useFeature; const z = useFeature.useProperty; - let t2; + let t0; if ($[3] !== useFeature || $[4] !== x || $[5] !== y || $[6] !== z) { - t2 = ( + t0 = ( {x} {y} @@ -66,11 +66,11 @@ function Component(t29) { $[4] = x; $[5] = y; $[6] = z; - $[7] = t2; + $[7] = t0; } else { - t2 = $[7]; + t0 = $[7]; } - return t2; + return t0; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md index c27aea1fee..bdb91a0e26 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-assignment-to-scope-declarations.expect.md @@ -47,8 +47,8 @@ function Component(statusName) { let t0; let t1; if ($[0] !== statusName) { - const { status, text: t47 } = foo(statusName); - text = t47; + const { status, text: t2 } = foo(statusName); + text = t2; const { bg, color } = getStyles(status); t1 = identity(bg); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md index a184412caa..9c30a623fc 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/sequential-destructuring-both-mixed-local-and-scope-declaration.expect.md @@ -50,11 +50,11 @@ function Component(statusName) { let text; let font; if ($[0] !== statusName) { - const { status, text: t49 } = foo(statusName); - text = t49; + const { status, text: t1 } = foo(statusName); + text = t1; - const { color, font: t50 } = getStyles(status); - font = t50; + const { color, font: t2 } = getStyles(status); + font = t2; t0 = identity(color); $[0] = statusName; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple.expect.md index f9db864301..641bd5aea9 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/simple.expect.md @@ -29,16 +29,16 @@ export default function foo(x, y) { return t0; } - const t1 = y * 10; - let t2; - if ($[2] !== t1) { - t2 = [t1]; - $[2] = t1; - $[3] = t2; + const t0 = y * 10; + let t1; + if ($[2] !== t0) { + t1 = [t0]; + $[2] = t0; + $[3] = t1; } else { - t2 = $[3]; + t1 = $[3]; } - return t2; + return t1; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md index 204e141965..29b4bd1beb 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md @@ -42,14 +42,14 @@ function foo(a) { const y = t0; x.y = y; } else { - let t1; + let t0; if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t1 = {}; - $[3] = t1; + t0 = {}; + $[3] = t0; } else { - t1 = $[3]; + t0 = $[3]; } - const z = t1; + const z = t0; x.z = z; } $[0] = a; diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md index 6b7125dd10..21a091a6ff 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md @@ -67,26 +67,26 @@ function Component(props) { x = $[1]; y = $[2]; } - let t1; + let t0; if ($[4] !== x) { - t1 = ; + t0 = ; $[4] = x; - $[5] = t1; + $[5] = t0; } else { - t1 = $[5]; + t0 = $[5]; } - const child = t1; + const child = t0; y.push(props.p4); - let t2; + let t1; if ($[6] !== y || $[7] !== child) { - t2 = {child}; + t1 = {child}; $[6] = y; $[7] = child; - $[8] = t2; + $[8] = t1; } else { - t2 = $[8]; + t1 = $[8]; } - return t2; + return t1; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/todo.unnecessary-lambda-memoization.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/todo.unnecessary-lambda-memoization.expect.md index ab141a1d6d..22fd973889 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/todo.unnecessary-lambda-memoization.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/todo.unnecessary-lambda-memoization.expect.md @@ -26,31 +26,31 @@ import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(5); const data = useFreeze(); - let t1; + let t0; if ($[0] !== data.items) { - let t0; + let t1; if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t0 = (item) => ; - $[2] = t0; + t1 = (item) => ; + $[2] = t1; } else { - t0 = $[2]; + t1 = $[2]; } - t1 = data.items.map(t0); + t0 = data.items.map(t1); $[0] = data.items; - $[1] = t1; + $[1] = t0; } else { - t1 = $[1]; + t0 = $[1]; } - const items = t1; - let t2; + const items = t0; + let t1; if ($[3] !== items) { - t2 =
{items}
; + t1 =
{items}
; $[3] = items; - $[4] = t2; + $[4] = t1; } else { - t2 = $[4]; + t1 = $[4]; } - return t2; + return t1; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md index 009fe6d34d..a822fc31ab 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/transitive-freeze-function-expressions.expect.md @@ -72,22 +72,22 @@ function Component(props) { t2 = $[6]; } useEffect(t1, t2); - let t4; + let t3; if ($[7] !== data) { - let t3; + let t4; if ($[9] === Symbol.for("react.memo_cache_sentinel")) { - t3 = (x) => x; - $[9] = t3; + t4 = (x) => x; + $[9] = t4; } else { - t3 = $[9]; + t4 = $[9]; } - t4 = data.map(t3); + t3 = data.map(t4); $[7] = data; - $[8] = t4; + $[8] = t3; } else { - t4 = $[8]; + t3 = $[8]; } - const items = t4; + const items = t3; return items; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch.expect.md index 022605becd..b10bce221b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-try-value-modified-in-catch.expect.md @@ -31,9 +31,9 @@ const { throwInput } = require("shared-runtime"); function Component(props) { const $ = useMemoCache(3); - let t49; + let t0; if ($[0] !== props.y || $[1] !== props.e) { - t49 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb18: { try { const y = []; @@ -42,21 +42,21 @@ function Component(props) { } catch (t25) { const e = t25; e.push(props.e); - t49 = e; + t0 = e; break bb18; } - t49 = null; + t0 = null; break bb18; } $[0] = props.y; $[1] = props.e; - $[2] = t49; + $[2] = t0; } else { - t49 = $[2]; + t0 = $[2]; } - if (t49 !== Symbol.for("react.early_return_sentinel")) { - return t49; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-catch-param.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-catch-param.expect.md index a067460741..c4ff0295df 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-catch-param.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-catch-param.expect.md @@ -32,9 +32,9 @@ const { throwInput } = require("shared-runtime"); function Component(props) { const $ = useMemoCache(1); - let t36; + let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t36 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb11: { const x = []; try { @@ -42,19 +42,19 @@ function Component(props) { } catch (t22) { const e = t22; e.push(null); - t36 = e; + t0 = e; break bb11; } - t36 = x; + t0 = x; break bb11; } - $[0] = t36; + $[0] = t0; } else { - t36 = $[0]; + t0 = $[0]; } - if (t36 !== Symbol.for("react.early_return_sentinel")) { - return t36; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-return.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-return.expect.md index e27d9fe584..ec26e252b7 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-return.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-with-return.expect.md @@ -34,32 +34,32 @@ const { shallowCopy, throwInput } = require("shared-runtime"); function Component(props) { const $ = useMemoCache(2); let x; - let t43; + let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t43 = Symbol.for("react.early_return_sentinel"); + t0 = Symbol.for("react.early_return_sentinel"); bb25: { x = []; try { const y = shallowCopy({}); if (y == null) { - t43 = undefined; + t0 = undefined; break bb25; } x.push(throwInput(y)); } catch { - t43 = null; + t0 = null; break bb25; } } $[0] = x; - $[1] = t43; + $[1] = t0; } else { x = $[0]; - t43 = $[1]; + t0 = $[1]; } - if (t43 !== Symbol.for("react.early_return_sentinel")) { - return t43; + if (t0 !== Symbol.for("react.early_return_sentinel")) { + return t0; } return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-within-mutable-range.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-within-mutable-range.expect.md index 5ebb8b62dd..b52dfe6dd4 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-within-mutable-range.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/try-catch-within-mutable-range.expect.md @@ -43,14 +43,14 @@ function Component(props) { } x.push(t0); } catch { - let t1; + let t0; if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t1 = shallowCopy({}); - $[3] = t1; + t0 = shallowCopy({}); + $[3] = t0; } else { - t1 = $[3]; + t0 = $[3]; } - x.push(t1); + x.push(t0); } x.push(props.value); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/type-annotations/todo_type-annotations-props.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/type-annotations/todo_type-annotations-props.expect.md index 8bd9db8a26..e3f3a806c5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/type-annotations/todo_type-annotations-props.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/type-annotations/todo_type-annotations-props.expect.md @@ -23,22 +23,22 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; // @enableUseTypeAnnotations function useArray(items) { const $ = useMemoCache(3); - let t1; + let t0; if ($[0] !== items) { - let t0; + let t1; if ($[2] === Symbol.for("react.memo_cache_sentinel")) { - t0 = (x) => x !== 0; - $[2] = t0; + t1 = (x) => x !== 0; + $[2] = t1; } else { - t0 = $[2]; + t1 = $[2]; } - t1 = items.filter(t0); + t0 = items.filter(t1); $[0] = items; - $[1] = t1; + $[1] = t0; } else { - t1 = $[1]; + t0 = $[1]; } - return t1; + return t0; } export const FIXTURE_ENTRYPOINT = { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md index 4ed82d43ae..48fa42eb6f 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md @@ -24,8 +24,8 @@ function Foo(props) { const $ = useMemoCache(2); let rest; if ($[0] !== props.a) { - const { unused, ...t15 } = props.a; - rest = t15; + const { unused, ...t0 } = props.a; + rest = t0; $[0] = props.a; $[1] = rest; } else { diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md index 138c2e643d..325cf9479b 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md @@ -20,18 +20,18 @@ function Component(props) { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(4); - let t20; + let t0; bb7: { if (props.cond) { - let t0; + let t1; if ($[0] !== props.a) { - t0 = makeObject(props.a); + t1 = makeObject(props.a); $[0] = props.a; - $[1] = t0; + $[1] = t1; } else { - t0 = $[1]; + t1 = $[1]; } - t20 = t0; + t0 = t1; break bb7; } let t1; @@ -42,9 +42,9 @@ function Component(props) { } else { t1 = $[3]; } - t20 = t1; + t0 = t1; } - const x = t20; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md index 8c0f09ea51..96986e2cf0 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md @@ -20,46 +20,46 @@ function Component(props) { import { unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(10); - let t26; let t0; - if ($[0] !== props.a) { - t0 = makeObject(props.a); - $[0] = props.a; - $[1] = t0; - } else { - t0 = $[1]; - } - const a = t0; let t1; - if ($[2] !== props.b) { - t1 = makeObject(props.b); - $[2] = props.b; - $[3] = t1; + if ($[0] !== props.a) { + t1 = makeObject(props.a); + $[0] = props.a; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - const b = t1; + const a = t1; let t2; + if ($[2] !== props.b) { + t2 = makeObject(props.b); + $[2] = props.b; + $[3] = t2; + } else { + t2 = $[3]; + } + const b = t2; + let t3; if ($[4] !== a || $[5] !== b) { - t2 = [a, b]; + t3 = [a, b]; $[4] = a; $[5] = b; - $[6] = t2; + $[6] = t3; } else { - t2 = $[6]; + t3 = $[6]; } - t26 = t2; - const [a_0, b_0] = t26; - let t3; + t0 = t3; + const [a_0, b_0] = t0; + let t4; if ($[7] !== a_0 || $[8] !== b_0) { - t3 = [a_0, b_0]; + t4 = [a_0, b_0]; $[7] = a_0; $[8] = b_0; - $[9] = t3; + $[9] = t4; } else { - t3 = $[9]; + t4 = $[9]; } - return t3; + return t4; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md index 61031e1ab0..2d32ce9c9d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md @@ -25,23 +25,23 @@ export const FIXTURE_ENTRYPOINT = { import { unstable_useMemoCache as useMemoCache } from "react"; function component(a, b) { const $ = useMemoCache(2); - let t13; + let t0; bb6: { if (a) { - let t0; + let t1; if ($[0] !== b) { - t0 = { b }; + t1 = { b }; $[0] = b; - $[1] = t0; + $[1] = t1; } else { - t0 = $[1]; + t1 = $[1]; } - t13 = t0; + t0 = t1; break bb6; } - t13 = undefined; + t0 = undefined; } - const x = t13; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inverted-if.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inverted-if.expect.md index 38a3a09b08..672bb6cc45 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inverted-if.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-inverted-if.expect.md @@ -27,20 +27,20 @@ export const FIXTURE_ENTRYPOINT = { ```javascript function Component(props) { - let t16; + let t0; bb10: { bb2: { if (props.cond) { break bb2; } - t16 = props.a; + t0 = props.a; break bb10; } - t16 = props.b; + t0 = props.b; } - const x = t16; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-labeled-statement-unconditional-return.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-labeled-statement-unconditional-return.expect.md index 3f589279e2..dfbefecffe 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-labeled-statement-unconditional-return.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-labeled-statement-unconditional-return.expect.md @@ -23,10 +23,10 @@ export const FIXTURE_ENTRYPOINT = { ```javascript function Component(props) { - let t8; + let t0; - t8 = props.value; - const x = t8; + t0 = props.value; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-logical.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-logical.expect.md index 34fe5a8de3..bf10ff649c 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-logical.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-logical.expect.md @@ -19,9 +19,9 @@ export const FIXTURE_ENTRYPOINT = { ```javascript function Component(props) { - let t16; - t16 = props.a && props.b; - const x = t16; + let t0; + t0 = props.a && props.b; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-dont-preserve-memoization-guarantees.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-dont-preserve-memoization-guarantees.expect.md index c113410428..b4cbfe60d6 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-dont-preserve-memoization-guarantees.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-dont-preserve-memoization-guarantees.expect.md @@ -56,13 +56,13 @@ function Component(props) { const part = free2.part; useHook(); - let t39; + let t0; const x = makeObject_Primitives(); x.value = props.value; mutate(x, free, part); - t39 = x; - const object = t39; + t0 = x; + const object = t0; identity(free); identity(part); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-preserve-memoization-guarantees.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-preserve-memoization-guarantees.expect.md index 1d351ee2be..b49247e9c7 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-preserve-memoization-guarantees.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-mabye-modified-free-variable-preserve-memoization-guarantees.expect.md @@ -76,7 +76,7 @@ function Component(props) { const part = free2.part; useHook(); - let t39; + let t2; let x; if ($[2] !== props.value) { x = makeObject_Primitives(); @@ -87,8 +87,8 @@ function Component(props) { } else { x = $[3]; } - t39 = x; - const object = t39; + t2 = x; + const object = t2; identity(free); identity(part); diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-dont-preserve-memoization-guarantees.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-dont-preserve-memoization-guarantees.expect.md index 7da8ef440c..53ca5660ab 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-dont-preserve-memoization-guarantees.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-dont-preserve-memoization-guarantees.expect.md @@ -28,17 +28,17 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime"; function Component(props) { const $ = useMemoCache(2); - let t7; + let t0; let object; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t7 = makeObject_Primitives(); - object = t7; + t0 = makeObject_Primitives(); + object = t0; identity(object); $[0] = object; - $[1] = t7; + $[1] = t0; } else { object = $[0]; - t7 = $[1]; + t0 = $[1]; } return object; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-preserve-memoization-guarantees.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-preserve-memoization-guarantees.expect.md index e2ab6a86bf..5198ec12ae 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-preserve-memoization-guarantees.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-maybe-modified-later-preserve-memoization-guarantees.expect.md @@ -28,16 +28,16 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime"; function Component(props) { const $ = useMemoCache(1); - let t7; let t0; + let t1; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { - t0 = makeObject_Primitives(); - $[0] = t0; + t1 = makeObject_Primitives(); + $[0] = t1; } else { - t0 = $[0]; + t1 = $[0]; } - t7 = t0; - const object = t7; + t0 = t1; + const object = t0; identity(object); return object; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md index 3ce6550027..f96b4a7bb6 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md @@ -33,7 +33,7 @@ import { useMemo, unstable_useMemoCache as useMemoCache } from "react"; function Component(props) { const $ = useMemoCache(3); - let t31; + let t0; bb9: { let y; if ($[0] !== props) { @@ -42,21 +42,21 @@ function Component(props) { y.push(props.a); } if (props.cond2) { - t31 = y; + t0 = y; break bb9; } y.push(props.b); $[0] = props; $[1] = y; - $[2] = t31; + $[2] = t0; } else { y = $[1]; - t31 = $[2]; + t0 = $[2]; } - t31 = y; + t0 = y; } - const x = t31; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md index eac323a512..6d703d2540 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md @@ -15,26 +15,26 @@ function component(a) { import { unstable_useMemoCache as useMemoCache } from "react"; function component(a) { const $ = useMemoCache(4); - let t9; let t0; - if ($[0] !== a) { - t0 = [a]; - $[0] = a; - $[1] = t0; - } else { - t0 = $[1]; - } - t9 = t0; - const x = t9; let t1; - if ($[2] !== x) { - t1 = ; - $[2] = x; - $[3] = t1; + if ($[0] !== a) { + t1 = [a]; + $[0] = a; + $[1] = t1; } else { - t1 = $[3]; + t1 = $[1]; } - return t1; + t0 = t1; + const x = t0; + let t2; + if ($[2] !== x) { + t2 = ; + $[2] = x; + $[3] = t2; + } else { + t2 = $[3]; + } + return t2; } ``` diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-no-fallthrough.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-no-fallthrough.expect.md index dc20920ed3..be9ff2ef50 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-no-fallthrough.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-no-fallthrough.expect.md @@ -28,17 +28,17 @@ export const FIXTURE_ENTRYPOINT = { ```javascript function Component(props) { - let t17; + let t0; bb8: switch (props.key) { case "key": { - t17 = props.value; + t0 = props.value; break bb8; } default: { - t17 = props.defaultValue; + t0 = props.defaultValue; } } - const x = t17; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-return.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-return.expect.md index 75c233f743..782db27c4f 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-return.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/useMemo-switch-return.expect.md @@ -34,12 +34,12 @@ export const FIXTURE_ENTRYPOINT = { ```javascript function Component(props) { - let t21; + let t0; bb10: { let y; bb2: switch (props.switch) { case "foo": { - t21 = "foo"; + t0 = "foo"; break bb10; } case "bar": { @@ -51,9 +51,9 @@ function Component(props) { } } - t21 = y; + t0 = y; } - const x = t21; + const x = t0; return x; } diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.expect.md index 6fce8dfa1c..cba57a4509 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/validate-no-set-state-in-render-uncalled-function-with-mutable-range-is-valid.expect.md @@ -62,33 +62,33 @@ function Component(props) { return t1; } case 1: { - let t2; + let t1; if ($[3] === Symbol.for("react.memo_cache_sentinel")) { - t2 = { foo: "joe" }; - $[3] = t2; + t1 = { foo: "joe" }; + $[3] = t1; } else { - t2 = $[3]; + t1 = $[3]; } - let t3; + let t2; if ($[4] !== onSubmit) { - t3 = ; + t2 = ; $[4] = onSubmit; - $[5] = t3; + $[5] = t2; } else { - t3 = $[5]; + t2 = $[5]; } - return t3; + return t2; } default: { logEvent("Invalid step"); - let t4; + let t1; if ($[6] === Symbol.for("react.memo_cache_sentinel")) { - t4 = ; - $[6] = t4; + t1 = ; + $[6] = t1; } else { - t4 = $[6]; + t1 = $[6]; } - return t4; + return t1; } } }