Compare commits

...

17 Commits

Author SHA1 Message Date
Joe Savona
f9de6284f7 [compiler] Errors for eval(), with statments, class declarations
* Error for `eval()`
* More specific error message for `with (expr) { ... }` syntax
* More specific error message for class declarations
2025-07-09 11:19:46 -07:00
Joseph Savona
ec4374c387 [compiler] Show logged errors in playground (#33740)
In playground it's helpful to show all errors, even those that don't
completely abort compilation. For example, to help demonstrate that the
compiler catches things like setState in effects. This detects these
errors and ensures we show them.
2025-07-09 09:22:49 -07:00
Sebastian Markbåge
60b5271a9a [Flight] Call finishHaltedTask on sync aborted tasks in stream abort listeners (#33743)
This is the same as we do for currently rendering tasks. They get
effectively sync aborted when the listener is invoked.

We potentially miss out on some debug info in that case but that would
only apply to any entries inside the stream which doesn't really have
their own debug info anyway.
2025-07-09 10:43:56 -04:00
Sebastian Markbåge
033edca721 [Flight] Yolo Retention of Promises (#33737)
Follow up to #33736.

If we need to save on CPU/memory pressure, we can instead just pray and
hope that a Promise doesn't get garbage collected before we need to read
it.

This can cause fragile access to the Promise value in devtools
especially if it's a slow and pressured render.

Basically, you'd have to hope that GC doesn't run after the inner await
finishes its microtask callback and before the resolution of the
component being rendered is invoked.
2025-07-09 10:39:08 -04:00
Sebastian Markbåge
e6dc25daea [Flight] Always defer Promise values if they're not already resolved (#33742)
If we have the ability to lazy load Promise values, i.e. if we have a
debug channel, then we should always use it for Promises that aren't
already resolved and instrumented.

There's little downside to this since they're async anyway.

This also lets us avoid adding `.then()` listeners too early. E.g. if
adding the listener would have side-effect. This avoids covering up
"unhandled rejection" errors. Since if we listen to a promise eagerly,
including reject listeners, we'd have marked that Promise's rejection as
handled where as maybe it wouldn't have been otherwise.

In this mode we can also indefinitely wait for the Promise to resolve
instead of just waiting a microtask for it to resolve.
2025-07-09 09:08:27 -04:00
Sebastian Markbåge
150f022444 [Flight] Ignore async stack frames when determining if a Promise was created from user space (#33739)
We use the stack of a Promise as the start of the I/O instead of the
actual I/O since that can symbolize the start of the operation even if
the actual I/O is batched, deduped or pooled. It can also group multiple
I/O operations into one.

We want the deepest possible Promise since otherwise it would just be
the Component's Promise.

However, we don't really need deeper than the boundary between first
party and third party. We can't just take the outer most that has third
party things on the stack though because third party can have callbacks
into first party and then we want the inner one. So we take the inner
most Promise that depends on I/O that has a first party stack on it.

The realization is that for the purposes of determining whether we have
a first party stack we need to ignore async stack frames. They can
appear on the stack when we resume third party code inside a resumption
frame of a first party stack.

<img width="832" alt="Screenshot 2025-07-08 at 6 34 25 PM"
src="https://github.com/user-attachments/assets/1636f980-be4c-4340-ad49-8d2b31953436"
/>

---------

Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
2025-07-09 09:08:09 -04:00
Sebastian Markbåge
49ded1d12a [Flight] Optimize Retention of Weak Promises Abit (#33736)
We don't really need to retain a reference to whatever Promise another
Promise was created in. Only awaits need to retain both their trigger
and their previous context.
2025-07-09 09:07:06 -04:00
Sebastian Markbåge
3a43e72d66 [Flight] Create a fast path parseStackTrace which skips generating a string stack (#33735)
When we know that the object that we pass in is immediately parsed, then
we know it couldn't have been reified into a unstructured stack yet. In
this path we assume that we'll trigger `Error.prepareStackTrace`.

Since we know that nobody else will read the stack after us, we can skip
generating a string stack and just return empty. We can also skip
caching.
2025-07-09 09:06:55 -04:00
Sebastian Markbåge
8ba3501cd9 [Flight] Don't dedupe references to deferred objects (#33741)
If we're about to defer an object, then we shouldn't store a reference
to it because then we can end up deduping by referring to the deferred
string. If in a different context, we should still be able to emit the
object.
2025-07-08 21:47:33 -04:00
Joseph Savona
956d770adf [compiler] Improve IIFE inlining (#33726)
We currently inline IIFEs by creating a temporary and a labeled block w
the original code. The original return statements turn into an
assignment to the temporary and break out of the label. However, many
cases of IIFEs are due to inlining of manual `useMemo()`, and these
cases often have only a single return statement. Here, the output is
cleaner if we avoid the temporary and label - so that's what we do in
this PR.

Note that the most complex part of the change is actually around
ValidatePreserveExistingMemo - we have some logic to track the IIFE
temporary reassignmetns which needs to be updated to handle the simpler
version of inlining.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33726).
* __->__ #33726
* #33725
2025-07-08 16:36:57 -07:00
Joseph Savona
d35fef9e21 [compiler] Fix for consecutive DCE'd branches with phis (#33725)
This is an optimized version of @asmjmp0's fix in
https://github.com/facebook/react/pull/31940. When we merge consecutive
blocks we need to take care to rewrite later phis whose operands will
now be different blocks due to merging. Rather than iterate all the
blocks on each merge as in #31940, we can do a single iteration over all
the phis at the end to fix them up.

Note: this is a redo of #31959

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33725).
* #33726
* __->__ #33725
2025-07-08 16:36:47 -07:00
Sebastian Markbåge
a7a116577d [Flight] Don't track Promise stack if there's no owner (#33734)
This is a compromise because there can be a lot of Promise instances
created. They're useful because they generally provide a better stack
when batching/pooled connections are used.

This restores stack collection for I/O nodes so we have something to
fallback on if there's no owner.

That way we can at least get a name or something out of I/O that was
spawned outside a render but mostly avoids collecting starting I/O
outside of render.
2025-07-08 13:02:29 -04:00
Sebastian Markbåge
777264b4ef [Flight] Fix stack getting object limited (#33733)
Because the object limit is unfortunately depth first due to limitations
of JSON stringify, we need to ensure that things we really don't want
outlined are first in the enumeration order.

We add the stack length to the object limit to ensure that the stack
frames aren't outlined. In console all the user space arguments are at
the end of the args. In server component props, the props are at the end
of the properties of the element.

For the `value` of I/O we had it before the stack so it could steal the
limit from the stack. The fix is to put it at the end.
2025-07-08 12:54:29 -04:00
Josh Story
befc1246b0 [Fizz] Render preamble eagerly (#33730)
We unnecessarily render the preamble in a task. This updates the
implementation to perform this render inline.

Testing this is tricky because one of the only ways you could assert
this was even happening is based on how things error if you abort while
rendering the root.

While adding a test for this I discovered that not all abortable tasks
report errors when aborted during a normal render. I've asserted the
current behavior and will address the other issue at another time and
updated the assertion later as necessary
2025-07-08 08:20:12 -07:00
Sebastian Markbåge
bbea677b77 [Flight] Lazy load objects from the debug channel (#33728)
When a debug channel is available, we now allow objects to be lazily
requested though the debug channel and only then will the server send
it.

The client will actually eagerly ask for the next level of objects once
it parses its payload. That way those objects have likely loaded by the
time you actually expand that deep e.g. in the console repl. This is
needed since the console repl is synchronous when you ask it to invoke
getters.

Each level is lazily parsed which means that we don't parse the next
level even though we eagerly loaded it. We parse it once the getter is
invoked (in Chrome DevTools you have to click a little `(...)` to invoke
the getter). When the getter is invoked, the chunk is initialized and
parsed. This then causes the next level to be asked for through the
debug channel. Ensuring that if you expand one more level you can do so
synchronously.

Currently debug chunks are eagerly parsed, which means that if you have
things like server component props that are lazy they can end up being
immediately asked for, but I'm trying to move to make the debug chunks
lazy.
2025-07-08 10:49:25 -04:00
Sebastian Markbåge
f1ecf82bfb [Flight] Optimize Async Stack Collection (#33727)
We need to optimize the collection of debug info for dev mode. This is
an incredibly hot path since it instruments all I/O and Promises in the
app.

These optimizations focus primarily on the collection of stack traces.
They are expensive to collect because we need to eagerly collect the
stacks since they can otherwise cause memory leaks. We also need to do
some of the processing of them up front. We also end up only using a few
of them in the end but we don't know which ones we'll use.

The first compromise here is that I now only collect the stacks of
"awaits" if they were in a specific request's render. In some cases it's
useful to collect them even outside of this if they're part of a
sequence that started early. I still collect stacks for the created
Promises outside of this though which can still provide some context.

The other optimization to awaits, is that since we'll only use the inner
most one that had an await directly in userspace, we can stop collecting
stacks on a chain of awaits after we find one. This requires a quick
filter on a single callsite to determine. Since we now only collect
stacks from awaits that belongs to a specific Request we can use that
request's specific filter option. Technically this might not be quite
correct if that same thing ends up deduped across Requests but that's an
edge case.

Additionally, I now stop collecting stack for I/O nodes. They're almost
always superseded by the Promise that wraps them anyway. Even if you
write mostly Promise free code, you'll likely end up with a Promise at
the root of the component eventually anyway and then you end up using
its stack anyway. You have to really contort the code to end up with
zero Promises at which point it's not very useful anyway. At best it's
maybe mostly useful for giving a name to the I/O when the rest is just
stuff like `new Promise`.

However, a possible alternative optimization could be to *only* collect
the stack of spawned I/O and not the stack of Promises. The issue with
Promises (not awaits) is that we never know what will end up resolving
them in the end when they're created so we have to always eagerly
collect stacks. This could be an issue when you have a lot of
abstractions that end up not actually be related to I/O at all. The
issue with collecting stacks only for I/O is that the actual I/O can be
pooled or batched so you end up not having the stack when the conceptual
start of each operation within the batch started. Which is why I decided
to keep the Promise stack.
2025-07-08 10:49:08 -04:00
Sebastian Markbåge
b44a99bf58 [Fiber] Name content inside "Suspense fallback" (#33724)
Same as #33723 but for Fiber.
2025-07-08 00:00:00 -04:00
115 changed files with 2515 additions and 1830 deletions

View File

@@ -44,6 +44,7 @@ import {
PrintedCompilerPipelineValue,
} from './Output';
import {transformFromAstSync} from '@babel/core';
import {LoggerEvent} from 'babel-plugin-react-compiler/dist/Entrypoint';
function parseInput(
input: string,
@@ -143,6 +144,7 @@ const COMMON_HOOKS: Array<[string, Hook]> = [
function compile(source: string): [CompilerOutput, 'flow' | 'typescript'] {
const results = new Map<string, Array<PrintedCompilerPipelineValue>>();
const error = new CompilerError();
const otherErrors: Array<CompilerErrorDetail> = [];
const upsert: (result: PrintedCompilerPipelineValue) => void = result => {
const entry = results.get(result.name);
if (Array.isArray(entry)) {
@@ -210,7 +212,11 @@ function compile(source: string): [CompilerOutput, 'flow' | 'typescript'] {
},
logger: {
debugLogIRs: logIR,
logEvent: () => {},
logEvent: (_filename: string | null, event: LoggerEvent) => {
if (event.kind === 'CompileError') {
otherErrors.push(new CompilerErrorDetail(event.detail));
}
},
},
});
transformOutput = invokeCompiler(source, language, opts);
@@ -237,6 +243,10 @@ function compile(source: string): [CompilerOutput, 'flow' | 'typescript'] {
);
}
}
// Only include logger errors if there weren't other errors
if (!error.hasErrors() && otherErrors.length !== 0) {
otherErrors.forEach(e => error.push(e));
}
if (error.hasErrors()) {
return [{kind: 'err', results, error: error}, language];
}

View File

@@ -1355,13 +1355,45 @@ function lowerStatement(
return;
}
case 'WithStatement': {
builder.errors.push({
reason: `JavaScript 'with' syntax is not supported`,
description: `'with' syntax is considered deprecated and removed from JavaScript standards, consider alternatives`,
severity: ErrorSeverity.InvalidJS,
loc: stmtPath.node.loc ?? null,
suggestions: null,
});
lowerValueToTemporary(builder, {
kind: 'UnsupportedNode',
loc: stmtPath.node.loc ?? GeneratedSource,
node: stmtPath.node,
});
return;
}
case 'ClassDeclaration': {
/*
* We can in theory support nested classes, similarly to functions where we track values
* captured by the class and consider mutations of the instances to mutate the class itself
*/
builder.errors.push({
reason: `Support nested class declarations`,
severity: ErrorSeverity.Todo,
loc: stmtPath.node.loc ?? null,
suggestions: null,
});
lowerValueToTemporary(builder, {
kind: 'UnsupportedNode',
loc: stmtPath.node.loc ?? GeneratedSource,
node: stmtPath.node,
});
return;
}
case 'TypeAlias':
case 'TSInterfaceDeclaration':
case 'TSTypeAliasDeclaration': {
// We do not preserve type annotations/syntax through transformation
return;
}
case 'ClassDeclaration':
case 'DeclareClass':
case 'DeclareExportAllDeclaration':
case 'DeclareExportDeclaration':
@@ -1384,8 +1416,7 @@ function lowerStatement(
case 'TSExportAssignment':
case 'TSImportEqualsDeclaration':
case 'TSModuleDeclaration':
case 'TSNamespaceExportDeclaration':
case 'WithStatement': {
case 'TSNamespaceExportDeclaration': {
builder.errors.push({
reason: `(BuildHIR::lowerStatement) Handle ${stmtPath.type} statements`,
severity: ErrorSeverity.Todo,
@@ -3502,6 +3533,16 @@ function lowerIdentifier(
return place;
}
default: {
if (binding.kind === 'Global' && binding.name === 'eval') {
builder.errors.push({
reason: `The 'eval' function is not supported`,
description:
'Eval is an anti-pattern in JavaScript, and the code executed cannot be evaluated by React Compiler',
severity: ErrorSeverity.InvalidJS,
loc: exprPath.node.loc ?? null,
suggestions: null,
});
}
return lowerValueToTemporary(builder, {
kind: 'LoadGlobal',
binding,

View File

@@ -107,6 +107,17 @@ export function mergeConsecutiveBlocks(fn: HIRFunction): void {
merged.merge(block.id, predecessorId);
fn.body.blocks.delete(block.id);
}
for (const [, block] of fn.body.blocks) {
for (const phi of block.phis) {
for (const [predecessorId, operand] of phi.operands) {
const mapped = merged.get(predecessorId);
if (mapped !== predecessorId) {
phi.operands.delete(predecessorId);
phi.operands.set(mapped, operand);
}
}
}
}
markPredecessors(fn.body);
for (const [, {terminal}] of fn.body.blocks) {
if (terminalHasFallthrough(terminal)) {

View File

@@ -715,7 +715,7 @@ export function printInstructionValue(instrValue: ReactiveValue): string {
break;
}
case 'FinishMemoize': {
value = `FinishMemoize decl=${printPlace(instrValue.decl)}`;
value = `FinishMemoize decl=${printPlace(instrValue.decl)}${instrValue.pruned ? ' pruned' : ''}`;
break;
}
default: {

View File

@@ -11,6 +11,7 @@ import {
Environment,
FunctionExpression,
GeneratedSource,
GotoTerminal,
GotoVariant,
HIRFunction,
IdentifierId,
@@ -19,6 +20,7 @@ import {
Place,
isStatementBlockKind,
makeInstructionId,
mergeConsecutiveBlocks,
promoteTemporary,
reversePostorderBlocks,
} from '../HIR';
@@ -73,6 +75,10 @@ import {retainWhere} from '../Utils/utils';
* - All return statements in the original function expression are replaced with a
* StoreLocal to the temporary we allocated before plus a Goto to the fallthrough
* block (code following the CallExpression).
*
* Note that if the inliined function has only one return, we avoid the labeled block
* and fully inline the code. The original return is replaced with an assignmen to the
* IIFE's call expression lvalue.
*/
export function inlineImmediatelyInvokedFunctionExpressions(
fn: HIRFunction,
@@ -146,37 +152,75 @@ export function inlineImmediatelyInvokedFunctionExpressions(
*/
block.instructions.length = ii;
/*
* To account for complex control flow within the lambda, we treat the lambda
* as if it were a single labeled statement, and replace all returns with gotos
* to the label fallthrough.
*/
const newTerminal: LabelTerminal = {
block: body.loweredFunc.func.body.entry,
id: makeInstructionId(0),
kind: 'label',
fallthrough: continuationBlockId,
loc: block.terminal.loc,
};
block.terminal = newTerminal;
if (hasSingleExitReturnTerminal(body.loweredFunc.func)) {
block.terminal = {
kind: 'goto',
block: body.loweredFunc.func.body.entry,
id: block.terminal.id,
loc: block.terminal.loc,
variant: GotoVariant.Break,
} as GotoTerminal;
for (const block of body.loweredFunc.func.body.blocks.values()) {
if (block.terminal.kind === 'return') {
block.instructions.push({
id: makeInstructionId(0),
loc: block.terminal.loc,
lvalue: instr.lvalue,
value: {
kind: 'LoadLocal',
loc: block.terminal.loc,
place: block.terminal.value,
},
effects: null,
});
block.terminal = {
kind: 'goto',
block: continuationBlockId,
id: block.terminal.id,
loc: block.terminal.loc,
variant: GotoVariant.Break,
} as GotoTerminal;
}
}
for (const [id, block] of body.loweredFunc.func.body.blocks) {
block.preds.clear();
fn.body.blocks.set(id, block);
}
} else {
/*
* To account for multiple returns within the lambda, we treat the lambda
* as if it were a single labeled statement, and replace all returns with gotos
* to the label fallthrough.
*/
const newTerminal: LabelTerminal = {
block: body.loweredFunc.func.body.entry,
id: makeInstructionId(0),
kind: 'label',
fallthrough: continuationBlockId,
loc: block.terminal.loc,
};
block.terminal = newTerminal;
// We store the result in the IIFE temporary
const result = instr.lvalue;
// We store the result in the IIFE temporary
const result = instr.lvalue;
// Declare the IIFE temporary
declareTemporary(fn.env, block, result);
// Declare the IIFE temporary
declareTemporary(fn.env, block, result);
// Promote the temporary with a name as we require this to persist
promoteTemporary(result.identifier);
// Promote the temporary with a name as we require this to persist
if (result.identifier.name == null) {
promoteTemporary(result.identifier);
}
/*
* Rewrite blocks from the lambda to replace any `return` with a
* store to the result and `goto` the continuation block
*/
for (const [id, block] of body.loweredFunc.func.body.blocks) {
block.preds.clear();
rewriteBlock(fn.env, block, continuationBlockId, result);
fn.body.blocks.set(id, block);
/*
* Rewrite blocks from the lambda to replace any `return` with a
* store to the result and `goto` the continuation block
*/
for (const [id, block] of body.loweredFunc.func.body.blocks) {
block.preds.clear();
rewriteBlock(fn.env, block, continuationBlockId, result);
fn.body.blocks.set(id, block);
}
}
/*
@@ -199,7 +243,7 @@ export function inlineImmediatelyInvokedFunctionExpressions(
if (inlinedFunctions.size !== 0) {
// Remove instructions that define lambdas which we inlined
for (const [, block] of fn.body.blocks) {
for (const block of fn.body.blocks.values()) {
retainWhere(
block.instructions,
instr => !inlinedFunctions.has(instr.lvalue.identifier.id),
@@ -213,9 +257,25 @@ export function inlineImmediatelyInvokedFunctionExpressions(
reversePostorderBlocks(fn.body);
markInstructionIds(fn.body);
markPredecessors(fn.body);
mergeConsecutiveBlocks(fn);
}
}
/**
* Returns true if the function has a single exit terminal (throw/return) which is a return
*/
function hasSingleExitReturnTerminal(fn: HIRFunction): boolean {
let hasReturn = false;
let exitCount = 0;
for (const [, block] of fn.body.blocks) {
if (block.terminal.kind === 'return' || block.terminal.kind === 'throw') {
hasReturn ||= block.terminal.kind === 'return';
exitCount++;
}
}
return exitCount === 1 && hasReturn;
}
/*
* Rewrites the block so that all `return` terminals are replaced:
* * Add a StoreLocal <returnValue> = <terminal.value>

View File

@@ -1064,12 +1064,29 @@ class PruneScopesTransform extends ReactiveFunctionTransform<
const value = instruction.value;
if (value.kind === 'StoreLocal' && value.lvalue.kind === 'Reassign') {
// Complex cases of useMemo inlining result in a temporary that is reassigned
const ids = getOrInsertDefault(
this.reassignments,
value.lvalue.place.identifier.declarationId,
new Set(),
);
ids.add(value.value.identifier);
} else if (
value.kind === 'LoadLocal' &&
value.place.identifier.scope != null &&
instruction.lvalue != null &&
instruction.lvalue.identifier.scope == null
) {
/*
* Simpler cases result in a direct assignment to the original lvalue, with a
* LoadLocal
*/
const ids = getOrInsertDefault(
this.reassignments,
instruction.lvalue.identifier.declarationId,
new Set(),
);
ids.add(value.place.identifier);
} else if (value.kind === 'FinishMemoize') {
let decls;
if (value.decl.identifier.scope == null) {

View File

@@ -445,11 +445,13 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
*/
this.recordTemporaries(instruction, state);
const value = instruction.value;
// Track reassignments from inlining of manual memo
if (
value.kind === 'StoreLocal' &&
value.lvalue.kind === 'Reassign' &&
state.manualMemoState != null
) {
// Complex cases of inlining end up with a temporary that is reassigned
const ids = getOrInsertDefault(
state.manualMemoState.reassignments,
value.lvalue.place.identifier.declarationId,
@@ -457,6 +459,21 @@ class Visitor extends ReactiveFunctionVisitor<VisitorState> {
);
ids.add(value.value.identifier);
}
if (
value.kind === 'LoadLocal' &&
value.place.identifier.scope != null &&
instruction.lvalue != null &&
instruction.lvalue.identifier.scope == null &&
state.manualMemoState != null
) {
// Simpler cases of inlining assign to the original IIFE lvalue
const ids = getOrInsertDefault(
state.manualMemoState.reassignments,
instruction.lvalue.identifier.declarationId,
new Set(),
);
ids.add(value.place.identifier);
}
if (value.kind === 'StartMemoize') {
let depsFromSource: Array<ManualMemoDependency> | null = null;
if (value.deps != null) {

View File

@@ -26,20 +26,16 @@ import { c as _c } from "react/compiler-runtime";
import { getNull } from "shared-runtime";
function Component(props) {
const $ = _c(3);
let t0;
const $ = _c(2);
let items;
if ($[0] !== props.a) {
t0 = getNull() ?? [];
items = t0;
items = getNull() ?? [];
items.push(props.a);
$[0] = props.a;
$[1] = items;
$[2] = t0;
} else {
items = $[1];
t0 = $[2];
}
return items;
}

View File

@@ -52,15 +52,13 @@ function Component(t0) {
}
const onClick = t1;
let t2;
let t3;
if ($[2] !== onClick) {
t3 = <div onClick={onClick}>{someGlobal.value}</div>;
t2 = <div onClick={onClick}>{someGlobal.value}</div>;
$[2] = onClick;
$[3] = t3;
$[3] = t2;
} else {
t3 = $[3];
t2 = $[3];
}
t2 = t3;
return t2;
}

View File

@@ -30,50 +30,46 @@ function Component(props) {
const $ = _c(4);
const [x] = useState(0);
let t0;
let t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const expensiveNumber = t0;
let t2;
let t1;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
function Component2(props) {
const $ = _c(4);
const [x] = useState(0);
let t0;
let t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const expensiveNumber = t0;
let t2;
let t1;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
```

View File

@@ -32,50 +32,46 @@ function Component(props) {
const $ = _c(4);
const [x] = useState(0);
let t0;
let t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const expensiveNumber = t0;
let t2;
let t1;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
function Component2(props) {
const $ = _c(4);
const [x] = useState(0);
let t0;
let t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const expensiveNumber = t0;
let t2;
let t1;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
```

View File

@@ -30,25 +30,23 @@ function Component(props) {
const $ = _c(4);
const [x] = React.useState(0);
let t0;
let t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const expensiveNumber = t0;
let t2;
let t1;
if ($[2] !== expensiveNumber) {
t2 = <div>{expensiveNumber}</div>;
t1 = <div>{expensiveNumber}</div>;
$[2] = expensiveNumber;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -36,30 +36,28 @@ function Component(props) {
const $ = _c(4);
const [x] = React.useState(0);
let t0;
let t1;
if ($[0] !== x) {
t1 = calculateExpensiveNumber(x);
t0 = calculateExpensiveNumber(x);
$[0] = x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const expensiveNumber = t0;
let t2;
let t1;
if ($[2] !== expensiveNumber) {
t2 = (
t1 = (
<div>
{expensiveNumber}
{`${someImport}`}
</div>
);
$[2] = expensiveNumber;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
return t2;
return t1;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -36,15 +36,14 @@ import { useMemo } from "react";
function Component(props) {
const $ = _c(2);
let t0;
let t1;
if ($[0] !== props.value) {
t1 = { value: props.value };
t0 = { value: props.value };
$[0] = props.value;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const handlers = t1;
const handlers = t0;
bb0: switch (props.test) {
case true: {
console.log(handlers.value);
@@ -52,9 +51,7 @@ function Component(props) {
}
default:
}
t0 = handlers;
const outerHandlers = t0;
const outerHandlers = handlers;
return outerHandlers;
}

View File

@@ -37,11 +37,9 @@ function useTest() {
const t1 = (w = 42);
const t2 = w;
let t3;
w = 999;
t3 = 2;
t0 = makeArray(t1, t2, t3);
t0 = makeArray(t1, t2, 2);
$[0] = t0;
} else {
t0 = $[0];

View File

@@ -37,11 +37,9 @@ function useTest() {
const t1 = (w.x = 42);
const t2 = w.x;
let t3;
w.x = 999;
t3 = 2;
t0 = makeArray(t1, t2, t3);
t0 = makeArray(t1, t2, 2);
$[0] = t0;
} else {
t0 = $[0];

View File

@@ -32,11 +32,9 @@ function useTest() {
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const t1 = print(1);
let t2;
print(2);
t2 = 2;
t0 = makeArray(t1, t2);
t0 = makeArray(t1, 2);
$[0] = t0;
} else {
t0 = $[0];

View File

@@ -29,37 +29,33 @@ function useHook(t0) {
const $ = _c(7);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = identity({ a });
t1 = identity({ a });
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const valA = t1;
let t3;
let t4;
let t2;
if ($[2] !== b) {
t4 = identity([b]);
t2 = identity([b]);
$[2] = b;
$[3] = t4;
$[3] = t2;
} else {
t4 = $[3];
t2 = $[3];
}
t3 = t4;
const valB = t3;
let t5;
const valB = t2;
let t3;
if ($[4] !== valA || $[5] !== valB) {
t5 = [valA, valB];
t3 = [valA, valB];
$[4] = valA;
$[5] = valB;
$[6] = t5;
$[6] = t3;
} else {
t5 = $[6];
t3 = $[6];
}
return t5;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -34,10 +34,8 @@ function Component(props) {
let Component;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
Component = Stringify;
let t0;
t0 = Component;
Component = t0;
Component = Component;
$[0] = Component;
} else {
Component = $[0];

View File

@@ -28,20 +28,18 @@ import { c as _c } from "react/compiler-runtime";
function Foo() {
const $ = _c(1);
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = function a(t2) {
const x_0 = t2 === undefined ? _temp : t2;
return (function b(t3) {
const y_0 = t3 === undefined ? [] : t3;
t0 = function a(t1) {
const x_0 = t1 === undefined ? _temp : t1;
return (function b(t2) {
const y_0 = t2 === undefined ? [] : t2;
return [x_0, y_0];
})();
};
$[0] = t1;
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
return t0;
}
function _temp() {}

View File

@@ -28,7 +28,6 @@ import * as React from "react";
function Component(props) {
const $ = _c(2);
let t0;
let x;
if ($[0] !== props.value) {
x = [];
@@ -38,8 +37,7 @@ function Component(props) {
} else {
x = $[1];
}
t0 = x;
const x_0 = t0;
const x_0 = x;
return x_0;
}

View File

@@ -0,0 +1,24 @@
## Input
```javascript
function Component(props) {
eval('props.x = true');
return <div />;
}
```
## Error
```
1 | function Component(props) {
> 2 | eval('props.x = true');
| ^^^^ InvalidJS: The 'eval' function is not supported. Eval is an anti-pattern in JavaScript, and the code executed cannot be evaluated by React Compiler (2:2)
3 | return <div />;
4 | }
5 |
```

View File

@@ -0,0 +1,4 @@
function Component(props) {
eval('props.x = true');
return <div />;
}

View File

@@ -84,7 +84,7 @@ let moduleLocal = false;
> 3 | var x = [];
| ^^^^^^^^^^^ Todo: (BuildHIR::lowerStatement) Handle var kinds in VariableDeclaration (3:3)
Todo: (BuildHIR::lowerStatement) Handle ClassDeclaration statements (5:10)
Todo: Support nested class declarations (5:10)
Todo: (BuildHIR::lowerStatement) Handle non-variable initialization in ForStatement (20:22)

View File

@@ -42,34 +42,32 @@ function Component(props) {
const c1 = __c;
const $c = c1;
let t0;
let t1;
if ($[0] !== $c) {
t1 = [$c];
t0 = [$c];
$[0] = $c;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const array = t0;
let t2;
let t1;
if ($[2] !== state) {
t2 = [state];
t1 = [state];
$[2] = state;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
let t3;
if ($[4] !== array || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={array} />;
let t2;
if ($[4] !== array || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={array} />;
$[4] = array;
$[5] = t2;
$[6] = t3;
$[5] = t1;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -63,23 +63,21 @@ function Component() {
unsafeUpdateConst();
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = [{ pretendConst }];
$[0] = t1;
t0 = [{ pretendConst }];
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
const value = t0;
let t2;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t2 = <ValidateMemoization inputs={[]} output={value} />;
$[1] = t2;
t1 = <ValidateMemoization inputs={[]} output={value} />;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
return t2;
return t1;
}
function _temp() {
unsafeResetConst();

View File

@@ -74,23 +74,21 @@ function Component() {
unsafeUpdateConst();
let t0;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = [{ pretendConst }];
$[1] = t1;
t0 = [{ pretendConst }];
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const value = t0;
let t2;
let t1;
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
t2 = <ValidateMemoization inputs={[pretendConst]} output={value} />;
$[2] = t2;
t1 = <ValidateMemoization inputs={[pretendConst]} output={value} />;
$[2] = t1;
} else {
t2 = $[2];
t1 = $[2];
}
return t2;
return t1;
}
function _temp() {
unsafeResetConst();

View File

@@ -38,36 +38,34 @@ function Component(props) {
$[0] = "20945b0193e529df490847c66111b38d7b02485d5b53d0829ff3b23af87b105c";
}
const [state] = useState(0);
let t0;
const t1 = state * 2;
const t0 = state * 2;
let t1;
if ($[1] !== t0) {
t1 = [t0];
$[1] = t0;
$[2] = t1;
} else {
t1 = $[2];
}
const doubled = t1;
let t2;
if ($[1] !== t1) {
t2 = [t1];
$[1] = t1;
$[2] = t2;
} else {
t2 = $[2];
}
t0 = t2;
const doubled = t0;
let t3;
if ($[3] !== state) {
t3 = [state];
t2 = [state];
$[3] = state;
$[4] = t3;
$[4] = t2;
} else {
t3 = $[4];
t2 = $[4];
}
let t4;
if ($[5] !== doubled || $[6] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={doubled} />;
let t3;
if ($[5] !== doubled || $[6] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={doubled} />;
$[5] = doubled;
$[6] = t3;
$[7] = t4;
$[6] = t2;
$[7] = t3;
} else {
t4 = $[7];
t3 = $[7];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -40,36 +40,34 @@ function Component(t0) {
const $ = _c(7);
const { data } = t0;
let t1;
let t2;
if ($[0] !== data.name) {
t2 = fbt._("{name}", [fbt._param("name", data.name ?? "")], {
t1 = fbt._("{name}", [fbt._param("name", data.name ?? "")], {
hk: "csQUH",
});
$[0] = data.name;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const el = t1;
let t3;
let t2;
if ($[2] !== data.name) {
t3 = [data.name];
t2 = [data.name];
$[2] = data.name;
$[3] = t3;
$[3] = t2;
} else {
t3 = $[3];
t2 = $[3];
}
let t4;
if ($[4] !== el || $[5] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={el} />;
let t3;
if ($[4] !== el || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={el} />;
$[4] = el;
$[5] = t3;
$[6] = t4;
$[5] = t2;
$[6] = t3;
} else {
t4 = $[6];
t3 = $[6];
}
return t4;
return t3;
}
const props1 = { data: { name: "Mike" } };

View File

@@ -47,17 +47,14 @@ function Component(t0) {
const $ = _c(19);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = [a];
t1 = [a];
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const x = t1;
let t3;
let items;
if ($[2] !== b || $[3] !== x) {
items = [b];
@@ -70,59 +67,57 @@ function Component(t0) {
} else {
items = $[4];
}
t3 = items;
const y = t3;
let t4;
const y = items;
let t2;
if ($[5] !== a) {
t4 = [a];
t2 = [a];
$[5] = a;
$[6] = t4;
$[6] = t2;
} else {
t4 = $[6];
t2 = $[6];
}
let t5;
if ($[7] !== t4 || $[8] !== x) {
t5 = <ValidateMemoization inputs={t4} output={x} />;
$[7] = t4;
let t3;
if ($[7] !== t2 || $[8] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[7] = t2;
$[8] = x;
$[9] = t5;
$[9] = t3;
} else {
t5 = $[9];
t3 = $[9];
}
let t6;
let t4;
if ($[10] !== b || $[11] !== x) {
t6 = [x, b];
t4 = [x, b];
$[10] = b;
$[11] = x;
$[12] = t6;
$[12] = t4;
} else {
t6 = $[12];
t4 = $[12];
}
let t7;
if ($[13] !== t6 || $[14] !== y) {
t7 = <ValidateMemoization inputs={t6} output={y} />;
$[13] = t6;
let t5;
if ($[13] !== t4 || $[14] !== y) {
t5 = <ValidateMemoization inputs={t4} output={y} />;
$[13] = t4;
$[14] = y;
$[15] = t7;
$[15] = t5;
} else {
t7 = $[15];
t5 = $[15];
}
let t8;
if ($[16] !== t5 || $[17] !== t7) {
t8 = (
let t6;
if ($[16] !== t3 || $[17] !== t5) {
t6 = (
<>
{t3}
{t5}
{t7}
</>
);
$[16] = t5;
$[17] = t7;
$[18] = t8;
$[16] = t3;
$[17] = t5;
$[18] = t6;
} else {
t8 = $[18];
t6 = $[18];
}
return t8;
return t6;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -34,7 +34,6 @@ import { ValidateMemoization } from "shared-runtime";
function Component(props) {
const $ = _c(7);
let t0;
let a;
if ($[0] !== props.name) {
a = [];
@@ -48,26 +47,25 @@ function Component(props) {
} else {
a = $[1];
}
t0 = a;
const a_0 = t0;
let t1;
const a_0 = a;
let t0;
if ($[2] !== props.name) {
t1 = [props.name];
t0 = [props.name];
$[2] = props.name;
$[3] = t1;
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
let t2;
if ($[4] !== a_0 || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={a_0} />;
let t1;
if ($[4] !== a_0 || $[5] !== t0) {
t1 = <ValidateMemoization inputs={t0} output={a_0} />;
$[4] = a_0;
$[5] = t1;
$[6] = t2;
$[5] = t0;
$[6] = t1;
} else {
t2 = $[6];
t1 = $[6];
}
return t2;
return t1;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -46,7 +46,7 @@ const React$useMemo = React.useMemo;
const Internal$Reassigned$useHook = useHook;
function Component() {
const $ = _c(8);
const $ = _c(7);
const [state] = React$useState(0);
const object = Internal$Reassigned$useHook();
let t0;
@@ -59,34 +59,30 @@ function Component() {
}
const json = t0;
let t1;
let t2;
if ($[2] !== state) {
t1 = makeArray(state);
const doubledArray = t1;
const doubledArray = makeArray(state);
t2 = doubledArray.join("");
t1 = doubledArray.join("");
$[2] = state;
$[3] = t2;
$[4] = t1;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[4];
t1 = $[3];
}
let t3;
if ($[5] !== json || $[6] !== t2) {
t3 = (
let t2;
if ($[4] !== json || $[5] !== t1) {
t2 = (
<div>
{t2}
{t1}
{json}
</div>
);
$[5] = json;
$[4] = json;
$[5] = t1;
$[6] = t2;
$[7] = t3;
} else {
t3 = $[7];
t2 = $[6];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -22,20 +22,16 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(3);
let t0;
const $ = _c(2);
let items;
if ($[0] !== props.a) {
t0 = [];
items = t0;
items = [];
items.push(props.a);
$[0] = props.a;
$[1] = items;
$[2] = t0;
} else {
items = $[1];
t0 = $[2];
}
return items;
}

View File

@@ -50,19 +50,17 @@ function useMakeCallback(t0) {
const [, setState] = useState(0);
let t1;
let t2;
if ($[0] !== obj.value) {
t2 = () => {
t1 = () => {
if (obj.value !== 0) {
setState(obj.value);
}
};
$[0] = obj.value;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const cb = t1;
useIdentity(null);

View File

@@ -26,17 +26,15 @@ import { c as _c } from "react/compiler-runtime";
function Foo() {
const $ = _c(1);
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = function a(t2) {
const x_0 = t2 === undefined ? _temp : t2;
t0 = function a(t1) {
const x_0 = t1 === undefined ? _temp : t1;
return x_0;
};
$[0] = t1;
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
return t0;
}
function _temp() {}

View File

@@ -37,13 +37,11 @@ import { useMemo } from "react";
import { identity, ValidateMemoization } from "shared-runtime";
function Component(t0) {
const $ = _c(10);
const $ = _c(9);
const { a, b } = t0;
let t1;
let x;
if ($[0] !== a || $[1] !== b) {
t1 = { a };
x = t1;
x = { a };
const f = () => identity(x);
const x2 = f();
@@ -51,30 +49,28 @@ function Component(t0) {
$[0] = a;
$[1] = b;
$[2] = x;
$[3] = t1;
} else {
x = $[2];
t1 = $[3];
}
let t1;
if ($[3] !== a || $[4] !== b) {
t1 = [a, b];
$[3] = a;
$[4] = b;
$[5] = t1;
} else {
t1 = $[5];
}
let t2;
if ($[4] !== a || $[5] !== b) {
t2 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t2;
if ($[6] !== t1 || $[7] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[6] = t1;
$[7] = x;
$[8] = t2;
} else {
t2 = $[6];
t2 = $[8];
}
let t3;
if ($[7] !== t2 || $[8] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[7] = t2;
$[8] = x;
$[9] = t3;
} else {
t3 = $[9];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -34,42 +34,38 @@ import { useMemo } from "react";
import { identity, ValidateMemoization } from "shared-runtime";
function Component(t0) {
const $ = _c(10);
const $ = _c(9);
const { a, b } = t0;
let t1;
let x;
if ($[0] !== a || $[1] !== b) {
t1 = { a };
x = t1;
x = { a };
const x2 = identity(x);
x2.b = b;
$[0] = a;
$[1] = b;
$[2] = x;
$[3] = t1;
} else {
x = $[2];
t1 = $[3];
}
let t1;
if ($[3] !== a || $[4] !== b) {
t1 = [a, b];
$[3] = a;
$[4] = b;
$[5] = t1;
} else {
t1 = $[5];
}
let t2;
if ($[4] !== a || $[5] !== b) {
t2 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t2;
if ($[6] !== t1 || $[7] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[6] = t1;
$[7] = x;
$[8] = t2;
} else {
t2 = $[6];
t2 = $[8];
}
let t3;
if ($[7] !== t2 || $[8] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[7] = t2;
$[8] = x;
$[9] = t3;
} else {
t3 = $[9];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -60,13 +60,11 @@ import {
} from "shared-runtime";
function Component(t0) {
const $ = _c(22);
const $ = _c(21);
const { a, b, c } = t0;
let t1;
let x;
if ($[0] !== a || $[1] !== b || $[2] !== c) {
t1 = [{ value: a }];
x = t1;
x = [{ value: a }];
if (b === 0) {
x.push({ value: c });
} else {
@@ -76,63 +74,61 @@ function Component(t0) {
$[1] = b;
$[2] = c;
$[3] = x;
$[4] = t1;
} else {
x = $[3];
t1 = $[4];
}
let t1;
if ($[4] !== a || $[5] !== b || $[6] !== c) {
t1 = [a, b, c];
$[4] = a;
$[5] = b;
$[6] = c;
$[7] = t1;
} else {
t1 = $[7];
}
let t2;
if ($[5] !== a || $[6] !== b || $[7] !== c) {
t2 = [a, b, c];
$[5] = a;
$[6] = b;
$[7] = c;
$[8] = t2;
if ($[8] !== t1 || $[9] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[8] = t1;
$[9] = x;
$[10] = t2;
} else {
t2 = $[8];
t2 = $[10];
}
let t3;
if ($[9] !== t2 || $[10] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[9] = t2;
$[10] = x;
$[11] = t3;
if ($[11] !== a || $[12] !== b || $[13] !== c) {
t3 = [a, b, c];
$[11] = a;
$[12] = b;
$[13] = c;
$[14] = t3;
} else {
t3 = $[11];
t3 = $[14];
}
let t4;
if ($[12] !== a || $[13] !== b || $[14] !== c) {
t4 = [a, b, c];
$[12] = a;
$[13] = b;
$[14] = c;
$[15] = t4;
if ($[15] !== t3 || $[16] !== x[0]) {
t4 = <ValidateMemoization inputs={t3} output={x[0]} />;
$[15] = t3;
$[16] = x[0];
$[17] = t4;
} else {
t4 = $[15];
t4 = $[17];
}
let t5;
if ($[16] !== t4 || $[17] !== x[0]) {
t5 = <ValidateMemoization inputs={t4} output={x[0]} />;
$[16] = t4;
$[17] = x[0];
$[18] = t5;
} else {
t5 = $[18];
}
let t6;
if ($[19] !== t3 || $[20] !== t5) {
t6 = (
if ($[18] !== t2 || $[19] !== t4) {
t5 = (
<>
{t3};{t5};
{t2};{t4};
</>
);
$[19] = t3;
$[18] = t2;
$[19] = t4;
$[20] = t5;
$[21] = t6;
} else {
t6 = $[21];
t5 = $[20];
}
return t6;
return t5;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -51,13 +51,11 @@ import {
} from "shared-runtime";
function Component(t0) {
const $ = _c(10);
const $ = _c(9);
const { a, b } = t0;
let t1;
let x;
if ($[0] !== a || $[1] !== b) {
t1 = [{ a }];
x = t1;
x = [{ a }];
const f = () => {
const y = typedCreateFrom(x);
const z = typedCapture(y);
@@ -70,30 +68,28 @@ function Component(t0) {
$[0] = a;
$[1] = b;
$[2] = x;
$[3] = t1;
} else {
x = $[2];
t1 = $[3];
}
let t1;
if ($[3] !== a || $[4] !== b) {
t1 = [a, b];
$[3] = a;
$[4] = b;
$[5] = t1;
} else {
t1 = $[5];
}
let t2;
if ($[4] !== a || $[5] !== b) {
t2 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t2;
if ($[6] !== t1 || $[7] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[6] = t1;
$[7] = x;
$[8] = t2;
} else {
t2 = $[6];
t2 = $[8];
}
let t3;
if ($[7] !== t2 || $[8] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[7] = t2;
$[8] = x;
$[9] = t3;
} else {
t3 = $[9];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -52,24 +52,20 @@ import {
} from "shared-runtime";
function Component(t0) {
const $ = _c(20);
const $ = _c(19);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = { a };
t1 = { a };
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const o = t1;
let t3;
let x;
if ($[2] !== b || $[3] !== o) {
t3 = [o];
x = t3;
x = [o];
const y = typedCapture(x);
const z = typedCapture(y);
x.push(z);
@@ -77,60 +73,58 @@ function Component(t0) {
$[2] = b;
$[3] = o;
$[4] = x;
$[5] = t3;
} else {
x = $[4];
t3 = $[5];
}
let t2;
if ($[5] !== a) {
t2 = [a];
$[5] = a;
$[6] = t2;
} else {
t2 = $[6];
}
let t3;
if ($[7] !== o || $[8] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={o} />;
$[7] = o;
$[8] = t2;
$[9] = t3;
} else {
t3 = $[9];
}
let t4;
if ($[6] !== a) {
t4 = [a];
$[6] = a;
$[7] = t4;
if ($[10] !== a || $[11] !== b) {
t4 = [a, b];
$[10] = a;
$[11] = b;
$[12] = t4;
} else {
t4 = $[7];
t4 = $[12];
}
let t5;
if ($[8] !== o || $[9] !== t4) {
t5 = <ValidateMemoization inputs={t4} output={o} />;
$[8] = o;
$[9] = t4;
$[10] = t5;
if ($[13] !== t4 || $[14] !== x) {
t5 = <ValidateMemoization inputs={t4} output={x} />;
$[13] = t4;
$[14] = x;
$[15] = t5;
} else {
t5 = $[10];
t5 = $[15];
}
let t6;
if ($[11] !== a || $[12] !== b) {
t6 = [a, b];
$[11] = a;
$[12] = b;
$[13] = t6;
} else {
t6 = $[13];
}
let t7;
if ($[14] !== t6 || $[15] !== x) {
t7 = <ValidateMemoization inputs={t6} output={x} />;
$[14] = t6;
$[15] = x;
$[16] = t7;
} else {
t7 = $[16];
}
let t8;
if ($[17] !== t5 || $[18] !== t7) {
t8 = (
if ($[16] !== t3 || $[17] !== t5) {
t6 = (
<>
{t5};{t7};
{t3};{t5};
</>
);
$[16] = t3;
$[17] = t5;
$[18] = t7;
$[19] = t8;
$[18] = t6;
} else {
t8 = $[19];
t6 = $[18];
}
return t8;
return t6;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -50,13 +50,11 @@ import {
} from "shared-runtime";
function Component(t0) {
const $ = _c(10);
const $ = _c(9);
const { a, b } = t0;
let t1;
let x;
if ($[0] !== a || $[1] !== b) {
t1 = { a };
x = t1;
x = { a };
const f = () => {
const y = typedCapture(x);
const z = typedCreateFrom(y);
@@ -69,30 +67,28 @@ function Component(t0) {
$[0] = a;
$[1] = b;
$[2] = x;
$[3] = t1;
} else {
x = $[2];
t1 = $[3];
}
let t1;
if ($[3] !== a || $[4] !== b) {
t1 = [a, b];
$[3] = a;
$[4] = b;
$[5] = t1;
} else {
t1 = $[5];
}
let t2;
if ($[4] !== a || $[5] !== b) {
t2 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t2;
if ($[6] !== t1 || $[7] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[6] = t1;
$[7] = x;
$[8] = t2;
} else {
t2 = $[6];
t2 = $[8];
}
let t3;
if ($[7] !== t2 || $[8] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[7] = t2;
$[8] = x;
$[9] = t3;
} else {
t3 = $[9];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -46,13 +46,11 @@ import {
} from "shared-runtime";
function Component(t0) {
const $ = _c(10);
const $ = _c(9);
const { a, b } = t0;
let t1;
let x;
if ($[0] !== a || $[1] !== b) {
t1 = { a };
x = t1;
x = { a };
const y = typedCapture(x);
const z = typedCreateFrom(y);
@@ -60,30 +58,28 @@ function Component(t0) {
$[0] = a;
$[1] = b;
$[2] = x;
$[3] = t1;
} else {
x = $[2];
t1 = $[3];
}
let t1;
if ($[3] !== a || $[4] !== b) {
t1 = [a, b];
$[3] = a;
$[4] = b;
$[5] = t1;
} else {
t1 = $[5];
}
let t2;
if ($[4] !== a || $[5] !== b) {
t2 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t2;
if ($[6] !== t1 || $[7] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[6] = t1;
$[7] = x;
$[8] = t2;
} else {
t2 = $[6];
t2 = $[8];
}
let t3;
if ($[7] !== t2 || $[8] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[7] = t2;
$[8] = x;
$[9] = t3;
} else {
t3 = $[9];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -49,38 +49,36 @@ function Component(t0) {
const $ = _c(7);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = [{ a }];
t1 = [{ a }];
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const x = t1;
const y = typedCreateFrom(x);
const z = typedCapture(y);
typedMutate(z, b);
let t3;
let t2;
if ($[2] !== a) {
t3 = [a];
t2 = [a];
$[2] = a;
$[3] = t3;
$[3] = t2;
} else {
t3 = $[3];
t2 = $[3];
}
let t4;
if ($[4] !== t3 || $[5] !== x) {
t4 = <ValidateMemoization inputs={t3} output={x} />;
$[4] = t3;
let t3;
if ($[4] !== t2 || $[5] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[4] = t2;
$[5] = x;
$[6] = t4;
$[6] = t3;
} else {
t4 = $[6];
t3 = $[6];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -50,21 +50,19 @@ import {
} from "shared-runtime";
function Component(t0) {
const $ = _c(12);
const $ = _c(11);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = { a };
t1 = { a };
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
let x;
if ($[2] !== b || $[3] !== t2) {
t1 = [t2];
x = t1;
if ($[2] !== b || $[3] !== t1) {
x = [t1];
let z;
if (b) {
z = x;
@@ -74,32 +72,30 @@ function Component(t0) {
typedMutate(z, b);
$[2] = b;
$[3] = t2;
$[3] = t1;
$[4] = x;
$[5] = t1;
} else {
x = $[4];
t1 = $[5];
}
let t2;
if ($[5] !== a || $[6] !== b) {
t2 = [a, b];
$[5] = a;
$[6] = b;
$[7] = t2;
} else {
t2 = $[7];
}
let t3;
if ($[6] !== a || $[7] !== b) {
t3 = [a, b];
$[6] = a;
$[7] = b;
$[8] = t3;
if ($[8] !== t2 || $[9] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[8] = t2;
$[9] = x;
$[10] = t3;
} else {
t3 = $[8];
t3 = $[10];
}
let t4;
if ($[9] !== t3 || $[10] !== x) {
t4 = <ValidateMemoization inputs={t3} output={x} />;
$[9] = t3;
$[10] = x;
$[11] = t4;
} else {
t4 = $[11];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -63,15 +63,13 @@ function Component(t0) {
const $ = _c(7);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = makeObject_Primitives(a);
t1 = makeObject_Primitives(a);
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const x = t1;
useIdentity(x);
@@ -79,24 +77,24 @@ function Component(t0) {
const x2 = typedIdentity(x);
identity(x2, b);
let t3;
let t2;
if ($[2] !== a) {
t3 = [a];
t2 = [a];
$[2] = a;
$[3] = t3;
$[3] = t2;
} else {
t3 = $[3];
t2 = $[3];
}
let t4;
if ($[4] !== t3 || $[5] !== x) {
t4 = <ValidateMemoization inputs={t3} output={x} />;
$[4] = t3;
let t3;
if ($[4] !== t2 || $[5] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[4] = t2;
$[5] = x;
$[6] = t4;
$[6] = t3;
} else {
t4 = $[6];
t3 = $[6];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -51,15 +51,13 @@ function useFoo(arr1, arr2) {
y = $[4];
}
let t1;
let t2;
if ($[5] !== y) {
t2 = { y };
t1 = { y };
$[5] = y;
$[6] = t2;
$[6] = t1;
} else {
t2 = $[6];
t1 = $[6];
}
t1 = t2;
return t1;
}

View File

@@ -42,36 +42,34 @@ function Component(t0) {
arg?.items.edges?.nodes;
let t1;
let t2;
if ($[0] !== arg?.items.edges?.nodes) {
t2 = arg?.items.edges?.nodes.map(identity);
t1 = arg?.items.edges?.nodes.map(identity);
$[0] = arg?.items.edges?.nodes;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const data = t1;
const t3 = arg?.items.edges?.nodes;
const t2 = arg?.items.edges?.nodes;
let t3;
if ($[2] !== t2) {
t3 = [t2];
$[2] = t2;
$[3] = t3;
} else {
t3 = $[3];
}
let t4;
if ($[2] !== t3) {
t4 = [t3];
$[2] = t3;
$[3] = t4;
} else {
t4 = $[3];
}
let t5;
if ($[4] !== data || $[5] !== t4) {
t5 = <ValidateMemoization inputs={t4} output={data} />;
if ($[4] !== data || $[5] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={data} />;
$[4] = data;
$[5] = t4;
$[6] = t5;
$[5] = t3;
$[6] = t4;
} else {
t5 = $[6];
t4 = $[6];
}
return t5;
return t4;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -23,21 +23,19 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
import { ValidateMemoization } from "shared-runtime";
function Component(props) {
const $ = _c(2);
let t0;
const x$0 = [];
x$0.push(props?.a.b?.c.d?.e);
x$0.push(props.a?.b.c?.d.e);
t0 = x$0;
let t1;
let t0;
if ($[0] !== props.a.b.c.d.e) {
t1 = <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />;
t0 = <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />;
$[0] = props.a.b.c.d.e;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
return t1;
return t0;
}
```

View File

@@ -23,7 +23,6 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
import { ValidateMemoization } from "shared-runtime";
function Component(props) {
const $ = _c(7);
let t0;
let x;
if ($[0] !== props.items) {
x = [];
@@ -34,26 +33,25 @@ function Component(props) {
} else {
x = $[1];
}
t0 = x;
const data = t0;
let t1;
const data = x;
let t0;
if ($[2] !== props.items) {
t1 = [props.items];
t0 = [props.items];
$[2] = props.items;
$[3] = t1;
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
let t2;
if ($[4] !== data || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={data} />;
let t1;
if ($[4] !== data || $[5] !== t0) {
t1 = <ValidateMemoization inputs={t0} output={data} />;
$[4] = data;
$[5] = t1;
$[6] = t2;
$[5] = t0;
$[6] = t1;
} else {
t2 = $[6];
t1 = $[6];
}
return t2;
return t1;
}
```

View File

@@ -38,7 +38,6 @@ function Component(t0) {
const { arg } = t0;
arg?.items;
let t1;
let x;
if ($[0] !== arg?.items) {
x = [];
@@ -48,27 +47,26 @@ function Component(t0) {
} else {
x = $[1];
}
t1 = x;
const data = t1;
const t2 = arg?.items;
const data = x;
const t1 = arg?.items;
let t2;
if ($[2] !== t1) {
t2 = [t1];
$[2] = t1;
$[3] = t2;
} else {
t2 = $[3];
}
let t3;
if ($[2] !== t2) {
t3 = [t2];
$[2] = t2;
$[3] = t3;
} else {
t3 = $[3];
}
let t4;
if ($[4] !== data || $[5] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={data} />;
if ($[4] !== data || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={data} />;
$[4] = data;
$[5] = t3;
$[6] = t4;
$[5] = t2;
$[6] = t3;
} else {
t4 = $[6];
t3 = $[6];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -36,11 +36,9 @@ import { useMemo } from "react";
// (i.e. inferred non-mutable or non-escaping values don't get memoized)
function useFoo(t0) {
const { minWidth, styles, setStyles } = t0;
let t1;
if (styles.width > minWidth) {
setStyles(styles);
}
t1 = undefined;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -34,10 +34,7 @@ import { identity } from "shared-runtime";
* This is technically a false positive, although it makes sense
* to bailout as source code might be doing something sketchy.
*/
function useFoo(x) {
let t0;
t0 = identity(x);
}
function useFoo(x) {}
export const FIXTURE_ENTRYPOINT = {
fn: useFoo,

View File

@@ -40,14 +40,12 @@ function useFoo() {
const $ = _c(1);
const constVal = 0;
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = [0];
$[0] = t1;
t0 = [0];
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
return t0;
}

View File

@@ -32,16 +32,14 @@ function Component(t0) {
const { propA, propB } = t0;
const x = propB.x.y;
let t1;
let t2;
if ($[0] !== propA.x || $[1] !== x) {
t2 = sum(propA.x, x);
t1 = sum(propA.x, x);
$[0] = propA.x;
$[1] = x;
$[2] = t2;
$[2] = t1;
} else {
t2 = $[2];
t1 = $[2];
}
t1 = t2;
return t1;
}

View File

@@ -32,28 +32,26 @@ import { identity } from "shared-runtime";
function Component(t0) {
const $ = _c(5);
const { propA, propB } = t0;
let t1;
const t2 = propB?.x.y;
const t1 = propB?.x.y;
let t2;
if ($[0] !== t1) {
t2 = identity(t1);
$[0] = t1;
$[1] = t2;
} else {
t2 = $[1];
}
let t3;
if ($[0] !== t2) {
t3 = identity(t2);
$[0] = t2;
$[1] = t3;
} else {
t3 = $[1];
}
let t4;
if ($[2] !== propA || $[3] !== t3) {
t4 = { value: t3, other: propA };
if ($[2] !== propA || $[3] !== t2) {
t3 = { value: t2, other: propA };
$[2] = propA;
$[3] = t3;
$[4] = t4;
$[3] = t2;
$[4] = t3;
} else {
t4 = $[4];
t3 = $[4];
}
t1 = t4;
return t1;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -30,20 +30,18 @@ import { useMemo } from "react";
function Component(t0) {
const $ = _c(3);
const { propA, propB } = t0;
let t1;
const t2 = propB?.x.y;
let t3;
if ($[0] !== propA || $[1] !== t2) {
t3 = { value: t2, other: propA };
const t1 = propB?.x.y;
let t2;
if ($[0] !== propA || $[1] !== t1) {
t2 = { value: t1, other: propA };
$[0] = propA;
$[1] = t2;
$[2] = t3;
$[1] = t1;
$[2] = t2;
} else {
t3 = $[2];
t2 = $[2];
}
t1 = t3;
return t1;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -37,39 +37,35 @@ function useFoo(cond) {
const $ = _c(5);
const sourceDep = 0;
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = identity(0);
$[0] = t1;
t0 = identity(0);
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
const derived1 = t0;
const derived2 = (cond ?? Math.min(0, 1)) ? 1 : 2;
let t2;
let t3;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t3 = identity(0);
$[1] = t3;
t1 = identity(0);
$[1] = t1;
} else {
t3 = $[1];
t1 = $[1];
}
t2 = t3;
const derived3 = t2;
const derived3 = t1;
const derived4 = (Math.min(0, -1) ?? cond) ? 1 : 2;
let t4;
let t2;
if ($[2] !== derived2 || $[3] !== derived4) {
t4 = [derived1, derived2, derived3, derived4];
t2 = [derived1, derived2, derived3, derived4];
$[2] = derived2;
$[3] = derived4;
$[4] = t4;
$[4] = t2;
} else {
t4 = $[4];
t2 = $[4];
}
return t4;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -48,15 +48,13 @@ function Foo(props) {
}
const x = t0;
let t1;
let t2;
if ($[2] !== x[0]) {
t2 = [x[0]];
t1 = [x[0]];
$[2] = x[0];
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
t1 = t2;
return t1;
}

View File

@@ -42,19 +42,17 @@ function useFoo(minWidth, otherProp) {
let t0;
if ($[0] !== minWidth || $[1] !== otherProp || $[2] !== width) {
const x = [];
let t1;
const t2 = Math.max(minWidth, width);
let t3;
if ($[4] !== t2) {
t3 = { width: t2 };
$[4] = t2;
$[5] = t3;
const t1 = Math.max(minWidth, width);
let t2;
if ($[4] !== t1) {
t2 = { width: t1 };
$[4] = t1;
$[5] = t2;
} else {
t3 = $[5];
t2 = $[5];
}
t1 = t3;
const style = t1;
const style = t2;
arrayPush(x, otherProp);
t0 = [style, x];

View File

@@ -29,15 +29,13 @@ import { useMemo } from "react";
function useFoo(a, b) {
const $ = _c(2);
let t0;
let t1;
if ($[0] !== a) {
t1 = [a];
t0 = [a];
$[0] = a;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
return t0;
}

View File

@@ -37,15 +37,13 @@ import { useMemo } from "react";
function useHook(x) {
const $ = _c(2);
let t0;
let t1;
if ($[0] !== x.y.z) {
t1 = [x.y.z];
t0 = [x.y.z];
$[0] = x.y.z;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
return t0;
}

View File

@@ -29,9 +29,7 @@ import { useMemo } from "react";
// It's correct to infer a useMemo value is non-allocating
// and not provide it with a reactive scope
function useFoo(num1, num2) {
let t0;
t0 = Math.min(num1, num2);
return t0;
return Math.min(num1, num2);
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -31,14 +31,12 @@ import { CONST_STRING0 } from "shared-runtime";
function useFoo() {
const $ = _c(1);
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = [CONST_STRING0];
$[0] = t1;
t0 = [CONST_STRING0];
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
return t0;
}

View File

@@ -30,25 +30,23 @@ import { identity } from "shared-runtime";
function useFoo(data) {
const $ = _c(4);
let t0;
let t1;
if ($[0] !== data.a) {
t1 = identity(data.a);
t0 = identity(data.a);
$[0] = data.a;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const temp = t1;
let t2;
const temp = t0;
let t1;
if ($[2] !== temp) {
t2 = { temp };
t1 = { temp };
$[2] = temp;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
t0 = t2;
return t0;
return t1;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -35,15 +35,13 @@ function useFoo(t0) {
const $ = _c(2);
const { callback } = t0;
let t1;
let t2;
if ($[0] !== callback) {
t2 = new Array(callback());
t1 = new Array(callback());
$[0] = callback;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
return t1;
}

View File

@@ -50,15 +50,13 @@ function useFoo(arr1, arr2) {
y = $[4];
}
let t1;
let t2;
if ($[5] !== y) {
t2 = { y };
t1 = { y };
$[5] = y;
$[6] = t2;
$[6] = t1;
} else {
t2 = $[6];
t1 = $[6];
}
t1 = t2;
return t1;
}

View File

@@ -49,14 +49,12 @@ function Foo(t0) {
let y = [];
let t2;
let t3;
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
t3 = { x: 2 };
$[5] = t3;
t2 = { x: 2 };
$[5] = t2;
} else {
t3 = $[5];
t2 = $[5];
}
t2 = t3;
val1 = t2;
foo ? (y = x.concat(arr2)) : y;

View File

@@ -33,15 +33,13 @@ function Component(t0) {
const $ = _c(2);
const { propA } = t0;
let t1;
let t2;
if ($[0] !== propA) {
t2 = [propA];
t1 = [propA];
$[0] = propA;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
return t1;
}

View File

@@ -42,36 +42,34 @@ function Component(t0) {
arg?.items.edges?.nodes;
let t1;
let t2;
if ($[0] !== arg?.items.edges?.nodes) {
t2 = arg?.items.edges?.nodes.map(identity);
t1 = arg?.items.edges?.nodes.map(identity);
$[0] = arg?.items.edges?.nodes;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const data = t1;
const t3 = arg?.items.edges?.nodes;
const t2 = arg?.items.edges?.nodes;
let t3;
if ($[2] !== t2) {
t3 = [t2];
$[2] = t2;
$[3] = t3;
} else {
t3 = $[3];
}
let t4;
if ($[2] !== t3) {
t4 = [t3];
$[2] = t3;
$[3] = t4;
} else {
t4 = $[3];
}
let t5;
if ($[4] !== data || $[5] !== t4) {
t5 = <ValidateMemoization inputs={t4} output={data} />;
if ($[4] !== data || $[5] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={data} />;
$[4] = data;
$[5] = t4;
$[6] = t5;
$[5] = t3;
$[6] = t4;
} else {
t5 = $[6];
t4 = $[6];
}
return t5;
return t4;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -23,21 +23,19 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
import { ValidateMemoization } from "shared-runtime";
function Component(props) {
const $ = _c(2);
let t0;
const x$0 = [];
x$0.push(props?.a.b?.c.d?.e);
x$0.push(props.a?.b.c?.d.e);
t0 = x$0;
let t1;
let t0;
if ($[0] !== props.a.b.c.d.e) {
t1 = <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />;
t0 = <ValidateMemoization inputs={[props.a.b.c.d.e]} output={x} />;
$[0] = props.a.b.c.d.e;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
return t1;
return t0;
}
```

View File

@@ -23,7 +23,6 @@ import { c as _c } from "react/compiler-runtime"; // @validatePreserveExistingMe
import { ValidateMemoization } from "shared-runtime";
function Component(props) {
const $ = _c(7);
let t0;
let x;
if ($[0] !== props.items) {
x = [];
@@ -34,26 +33,25 @@ function Component(props) {
} else {
x = $[1];
}
t0 = x;
const data = t0;
let t1;
const data = x;
let t0;
if ($[2] !== props.items) {
t1 = [props.items];
t0 = [props.items];
$[2] = props.items;
$[3] = t1;
$[3] = t0;
} else {
t1 = $[3];
t0 = $[3];
}
let t2;
if ($[4] !== data || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={data} />;
let t1;
if ($[4] !== data || $[5] !== t0) {
t1 = <ValidateMemoization inputs={t0} output={data} />;
$[4] = data;
$[5] = t1;
$[6] = t2;
$[5] = t0;
$[6] = t1;
} else {
t2 = $[6];
t1 = $[6];
}
return t2;
return t1;
}
```

View File

@@ -38,7 +38,6 @@ function Component(t0) {
const { arg } = t0;
arg?.items;
let t1;
let x;
if ($[0] !== arg?.items) {
x = [];
@@ -48,27 +47,26 @@ function Component(t0) {
} else {
x = $[1];
}
t1 = x;
const data = t1;
const t2 = arg?.items;
const data = x;
const t1 = arg?.items;
let t2;
if ($[2] !== t1) {
t2 = [t1];
$[2] = t1;
$[3] = t2;
} else {
t2 = $[3];
}
let t3;
if ($[2] !== t2) {
t3 = [t2];
$[2] = t2;
$[3] = t3;
} else {
t3 = $[3];
}
let t4;
if ($[4] !== data || $[5] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={data} />;
if ($[4] !== data || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={data} />;
$[4] = data;
$[5] = t3;
$[6] = t4;
$[5] = t2;
$[6] = t3;
} else {
t4 = $[6];
t3 = $[6];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -31,34 +31,32 @@ import { ValidateMemoization } from "shared-runtime";
function Component(props) {
const $ = _c(7);
let t0;
let t1;
if ($[0] !== props.x) {
t1 = props.x();
t0 = props.x();
$[0] = props.x;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const x = t0;
let t2;
let t1;
if ($[2] !== props.x) {
t2 = [props.x];
t1 = [props.x];
$[2] = props.x;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
let t3;
if ($[4] !== t2 || $[5] !== x) {
t3 = <ValidateMemoization inputs={t2} output={x} />;
$[4] = t2;
let t2;
if ($[4] !== t1 || $[5] !== x) {
t2 = <ValidateMemoization inputs={t1} output={x} />;
$[4] = t1;
$[5] = x;
$[6] = t3;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
return t3;
return t2;
}
const f = () => ["React"];

View File

@@ -23,9 +23,7 @@ function foo(x) {
if (x <= 0) {
return 0;
}
let t0;
t0 = foo(x - 2);
return x + foo(x - 1) + t0;
return x + foo(x - 1) + foo(x - 2);
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -59,48 +59,46 @@ function Component(t0) {
const $ = _c(9);
const { config } = t0;
let t1;
let t2;
if ($[0] !== config) {
t2 = (event) => {
t1 = (event) => {
config?.onA?.(event);
};
$[0] = config;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
const a = t2;
let t3;
const a = t1;
let t2;
if ($[2] !== config) {
t3 = (event_0) => {
t2 = (event_0) => {
config?.onB?.(event_0);
};
$[2] = config;
$[3] = t3;
$[3] = t2;
} else {
t3 = $[3];
t2 = $[3];
}
const b = t3;
let t4;
const b = t2;
let t3;
if ($[4] !== a || $[5] !== b) {
t4 = { b, a };
t3 = { b, a };
$[4] = a;
$[5] = b;
$[6] = t4;
$[6] = t3;
} else {
t4 = $[6];
t3 = $[6];
}
t1 = t4;
const object = t1;
let t5;
const object = t3;
let t4;
if ($[7] !== object) {
t5 = <Stringify value={object} />;
t4 = <Stringify value={object} />;
$[7] = object;
$[8] = t5;
$[8] = t4;
} else {
t5 = $[8];
t4 = $[8];
}
return t5;
return t4;
}
```

View File

@@ -65,20 +65,18 @@ function Component() {
}
const filtered = t2;
let t3;
let t4;
if ($[6] !== filtered) {
t4 = filtered.map();
t3 = filtered.map();
$[6] = filtered;
$[7] = t4;
$[7] = t3;
} else {
t4 = $[7];
t3 = $[7];
}
t3 = t4;
const map = t3;
const index = filtered.findIndex(_temp3);
let t5;
let t4;
if ($[8] !== index || $[9] !== map) {
t5 = (
t4 = (
<div>
{map}
{index}
@@ -86,11 +84,11 @@ function Component() {
);
$[8] = index;
$[9] = map;
$[10] = t5;
$[10] = t4;
} else {
t5 = $[10];
t4 = $[10];
}
return t5;
return t4;
}
function _temp3(x) {
return x === null;

View File

@@ -62,20 +62,18 @@ function Component() {
}
const filtered = t2;
let t3;
let t4;
if ($[6] !== filtered) {
t4 = filtered.map();
t3 = filtered.map();
$[6] = filtered;
$[7] = t4;
$[7] = t3;
} else {
t4 = $[7];
t3 = $[7];
}
t3 = t4;
const map = t3;
const index = filtered.findIndex(_temp3);
let t5;
let t4;
if ($[8] !== index || $[9] !== map) {
t5 = (
t4 = (
<div>
{map}
{index}
@@ -83,11 +81,11 @@ function Component() {
);
$[8] = index;
$[9] = map;
$[10] = t5;
$[10] = t4;
} else {
t5 = $[10];
t4 = $[10];
}
return t5;
return t4;
}
function _temp3(x) {
return x === null;

View File

@@ -0,0 +1,52 @@
## Input
```javascript
function Component() {
let v3, v4, acc;
v3 = false;
v4 = v3;
acc = v3;
if (acc) {
acc = true;
v3 = acc;
}
if (acc) {
v3 = v4;
}
v4 = v3;
return [acc, v3, v4];
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};
```
## Code
```javascript
import { c as _c } from "react/compiler-runtime";
function Component() {
const $ = _c(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = [false, false, false];
$[0] = t0;
} else {
t0 = $[0];
}
return t0;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};
```
### Eval output
(kind: ok) [false,false,false]

View File

@@ -0,0 +1,20 @@
function Component() {
let v3, v4, acc;
v3 = false;
v4 = v3;
acc = v3;
if (acc) {
acc = true;
v3 = acc;
}
if (acc) {
v3 = v4;
}
v4 = v3;
return [acc, v3, v4];
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
};

View File

@@ -39,55 +39,51 @@ function Component() {
```javascript
import { c as _c } from "react/compiler-runtime"; // @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions
function Component() {
const $ = _c(7);
const $ = _c(6);
const items = useItems();
let t0;
let t1;
let t2;
if ($[0] !== items) {
t2 = Symbol.for("react.early_return_sentinel");
t1 = Symbol.for("react.early_return_sentinel");
bb0: {
t0 = items.filter(_temp);
const filteredItems = t0;
const filteredItems = items.filter(_temp);
if (filteredItems.length === 0) {
let t3;
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
t3 = (
let t2;
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
t2 = (
<div>
<span />
</div>
);
$[4] = t3;
$[3] = t2;
} else {
t3 = $[4];
t2 = $[3];
}
t2 = t3;
t1 = t2;
break bb0;
}
t1 = filteredItems.map(_temp2);
t0 = filteredItems.map(_temp2);
}
$[0] = items;
$[1] = t1;
$[2] = t2;
$[3] = t0;
$[1] = t0;
$[2] = t1;
} else {
t1 = $[1];
t2 = $[2];
t0 = $[3];
t0 = $[1];
t1 = $[2];
}
if (t2 !== Symbol.for("react.early_return_sentinel")) {
return t2;
if (t1 !== Symbol.for("react.early_return_sentinel")) {
return t1;
}
let t3;
if ($[5] !== t1) {
t3 = <>{t1}</>;
$[5] = t1;
$[6] = t3;
let t2;
if ($[4] !== t0) {
t2 = <>{t0}</>;
$[4] = t0;
$[5] = t2;
} else {
t3 = $[6];
t2 = $[5];
}
return t3;
return t2;
}
function _temp2(t0) {
const [item_0] = t0;

View File

@@ -45,87 +45,83 @@ import { Stringify, identity, makeArray, toJSON } from "shared-runtime";
import { useMemo } from "react";
function Component(props) {
const $ = _c(13);
const $ = _c(12);
let t0;
let t1;
let t2;
if ($[0] !== props) {
t2 = Symbol.for("react.early_return_sentinel");
t1 = Symbol.for("react.early_return_sentinel");
bb0: {
t0 = toJSON(props);
const propsString = t0;
const propsString = toJSON(props);
if (propsString.length <= 2) {
t2 = null;
t1 = null;
break bb0;
}
t1 = identity(propsString);
t0 = identity(propsString);
}
$[0] = props;
$[1] = t1;
$[2] = t2;
$[1] = t0;
$[2] = t1;
} else {
t0 = $[1];
t1 = $[2];
}
if (t1 !== Symbol.for("react.early_return_sentinel")) {
return t1;
}
let t2;
if ($[3] !== t0) {
t2 = { url: t0 };
$[3] = t0;
$[4] = t2;
} else {
t1 = $[1];
t2 = $[2];
t0 = $[3];
}
if (t2 !== Symbol.for("react.early_return_sentinel")) {
return t2;
t2 = $[4];
}
const linkProps = t2;
let t3;
if ($[4] !== t1) {
t3 = { url: t1 };
$[4] = t1;
$[5] = t3;
} else {
t3 = $[5];
}
const linkProps = t3;
let t4;
if ($[6] !== linkProps) {
if ($[5] !== linkProps) {
const x = {};
let t4;
let t5;
let t6;
let t7;
let t8;
let t9;
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
t5 = [1];
t6 = [2];
t7 = [3];
t8 = [4];
t9 = [5];
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
t4 = [1];
t5 = [2];
t6 = [3];
t7 = [4];
t8 = [5];
$[7] = t4;
$[8] = t5;
$[9] = t6;
$[10] = t7;
$[11] = t8;
$[12] = t9;
} else {
t4 = $[7];
t5 = $[8];
t6 = $[9];
t7 = $[10];
t8 = $[11];
t9 = $[12];
}
t4 = (
t3 = (
<Stringify
link={linkProps}
val1={t5}
val2={t6}
val3={t7}
val4={t8}
val5={t9}
val1={t4}
val2={t5}
val3={t6}
val4={t7}
val5={t8}
>
{makeArray(x, 2)}
</Stringify>
);
$[6] = linkProps;
$[7] = t4;
$[5] = linkProps;
$[6] = t3;
} else {
t4 = $[7];
t3 = $[6];
}
return t4;
return t3;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -24,10 +24,9 @@ function Component(props) {
```javascript
import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(7);
const $ = _c(6);
const item = props.item;
let baseVideos;
let t0;
let thumbnails;
if ($[0] !== item) {
thumbnails = [];
@@ -41,24 +40,21 @@ function Component(props) {
});
$[0] = item;
$[1] = baseVideos;
$[2] = t0;
$[3] = thumbnails;
$[2] = thumbnails;
} else {
baseVideos = $[1];
t0 = $[2];
thumbnails = $[3];
thumbnails = $[2];
}
t0 = undefined;
let t1;
if ($[4] !== baseVideos || $[5] !== thumbnails) {
t1 = <FlatList baseVideos={baseVideos} items={thumbnails} />;
$[4] = baseVideos;
$[5] = thumbnails;
$[6] = t1;
let t0;
if ($[3] !== baseVideos || $[4] !== thumbnails) {
t0 = <FlatList baseVideos={baseVideos} items={thumbnails} />;
$[3] = baseVideos;
$[4] = thumbnails;
$[5] = t0;
} else {
t1 = $[6];
t0 = $[5];
}
return t1;
return t0;
}
```

View File

@@ -47,77 +47,73 @@ export function Component(t0) {
const $ = _c(17);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = { a };
t1 = { a };
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const item1 = t1;
let t3;
let t4;
let t2;
if ($[2] !== b) {
t4 = { b };
t2 = { b };
$[2] = b;
$[3] = t4;
$[3] = t2;
} else {
t4 = $[3];
t2 = $[3];
}
t3 = t4;
const item2 = t3;
const item2 = t2;
typedLog(item1, item2);
let t5;
let t3;
if ($[4] !== a) {
t5 = [a];
t3 = [a];
$[4] = a;
$[5] = t5;
$[5] = t3;
} else {
t5 = $[5];
t3 = $[5];
}
let t4;
if ($[6] !== item1 || $[7] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={item1} />;
$[6] = item1;
$[7] = t3;
$[8] = t4;
} else {
t4 = $[8];
}
let t5;
if ($[9] !== b) {
t5 = [b];
$[9] = b;
$[10] = t5;
} else {
t5 = $[10];
}
let t6;
if ($[6] !== item1 || $[7] !== t5) {
t6 = <ValidateMemoization inputs={t5} output={item1} />;
$[6] = item1;
$[7] = t5;
$[8] = t6;
if ($[11] !== item2 || $[12] !== t5) {
t6 = <ValidateMemoization inputs={t5} output={item2} />;
$[11] = item2;
$[12] = t5;
$[13] = t6;
} else {
t6 = $[8];
t6 = $[13];
}
let t7;
if ($[9] !== b) {
t7 = [b];
$[9] = b;
$[10] = t7;
} else {
t7 = $[10];
}
let t8;
if ($[11] !== item2 || $[12] !== t7) {
t8 = <ValidateMemoization inputs={t7} output={item2} />;
$[11] = item2;
$[12] = t7;
$[13] = t8;
} else {
t8 = $[13];
}
let t9;
if ($[14] !== t6 || $[15] !== t8) {
t9 = (
if ($[14] !== t4 || $[15] !== t6) {
t7 = (
<>
{t4}
{t6}
{t8}
</>
);
$[14] = t6;
$[15] = t8;
$[16] = t9;
$[14] = t4;
$[15] = t6;
$[16] = t7;
} else {
t9 = $[16];
t7 = $[16];
}
return t9;
return t7;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -45,77 +45,73 @@ export function Component(t0) {
const $ = _c(17);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = { a };
t1 = { a };
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const item1 = t1;
let t3;
let t4;
let t2;
if ($[2] !== b) {
t4 = { b };
t2 = { b };
$[2] = b;
$[3] = t4;
$[3] = t2;
} else {
t4 = $[3];
t2 = $[3];
}
t3 = t4;
const item2 = t3;
const item2 = t2;
typedLog(item1, item2);
let t5;
let t3;
if ($[4] !== a) {
t5 = [a];
t3 = [a];
$[4] = a;
$[5] = t5;
$[5] = t3;
} else {
t5 = $[5];
t3 = $[5];
}
let t4;
if ($[6] !== item1 || $[7] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={item1} />;
$[6] = item1;
$[7] = t3;
$[8] = t4;
} else {
t4 = $[8];
}
let t5;
if ($[9] !== b) {
t5 = [b];
$[9] = b;
$[10] = t5;
} else {
t5 = $[10];
}
let t6;
if ($[6] !== item1 || $[7] !== t5) {
t6 = <ValidateMemoization inputs={t5} output={item1} />;
$[6] = item1;
$[7] = t5;
$[8] = t6;
if ($[11] !== item2 || $[12] !== t5) {
t6 = <ValidateMemoization inputs={t5} output={item2} />;
$[11] = item2;
$[12] = t5;
$[13] = t6;
} else {
t6 = $[8];
t6 = $[13];
}
let t7;
if ($[9] !== b) {
t7 = [b];
$[9] = b;
$[10] = t7;
} else {
t7 = $[10];
}
let t8;
if ($[11] !== item2 || $[12] !== t7) {
t8 = <ValidateMemoization inputs={t7} output={item2} />;
$[11] = item2;
$[12] = t7;
$[13] = t8;
} else {
t8 = $[13];
}
let t9;
if ($[14] !== t6 || $[15] !== t8) {
t9 = (
if ($[14] !== t4 || $[15] !== t6) {
t7 = (
<>
{t4}
{t6}
{t8}
</>
);
$[14] = t6;
$[15] = t8;
$[16] = t9;
$[14] = t4;
$[15] = t6;
$[16] = t7;
} else {
t9 = $[16];
t7 = $[16];
}
return t9;
return t7;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -51,28 +51,23 @@ export function Component(t0) {
const $ = _c(27);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = { a };
t1 = { a };
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const item1 = t1;
let t3;
let t4;
let t2;
if ($[2] !== b) {
t4 = { b };
t2 = { b };
$[2] = b;
$[3] = t4;
$[3] = t2;
} else {
t4 = $[3];
t2 = $[3];
}
t3 = t4;
const item2 = t3;
let t5;
const item2 = t2;
let items;
if ($[4] !== item1 || $[5] !== item2) {
items = [];
@@ -84,77 +79,76 @@ export function Component(t0) {
} else {
items = $[6];
}
t5 = items;
const items_0 = t5;
let t6;
const items_0 = items;
let t3;
if ($[7] !== a) {
t6 = [a];
t3 = [a];
$[7] = a;
$[8] = t6;
$[8] = t3;
} else {
t6 = $[8];
t3 = $[8];
}
let t4;
if ($[9] !== items_0[0] || $[10] !== t3) {
t4 = <SharedRuntime.ValidateMemoization inputs={t3} output={items_0[0]} />;
$[9] = items_0[0];
$[10] = t3;
$[11] = t4;
} else {
t4 = $[11];
}
let t5;
if ($[12] !== b) {
t5 = [b];
$[12] = b;
$[13] = t5;
} else {
t5 = $[13];
}
let t6;
if ($[14] !== items_0[1] || $[15] !== t5) {
t6 = <SharedRuntime.ValidateMemoization inputs={t5} output={items_0[1]} />;
$[14] = items_0[1];
$[15] = t5;
$[16] = t6;
} else {
t6 = $[16];
}
let t7;
if ($[9] !== items_0[0] || $[10] !== t6) {
t7 = <SharedRuntime.ValidateMemoization inputs={t6} output={items_0[0]} />;
$[9] = items_0[0];
$[10] = t6;
$[11] = t7;
} else {
t7 = $[11];
}
let t8;
if ($[12] !== b) {
t8 = [b];
$[12] = b;
$[13] = t8;
} else {
t8 = $[13];
}
let t9;
if ($[14] !== items_0[1] || $[15] !== t8) {
t9 = <SharedRuntime.ValidateMemoization inputs={t8} output={items_0[1]} />;
$[14] = items_0[1];
$[15] = t8;
$[16] = t9;
} else {
t9 = $[16];
}
let t10;
if ($[17] !== a || $[18] !== b) {
t10 = [a, b];
t7 = [a, b];
$[17] = a;
$[18] = b;
$[19] = t10;
$[19] = t7;
} else {
t10 = $[19];
t7 = $[19];
}
let t11;
if ($[20] !== items_0 || $[21] !== t10) {
t11 = <SharedRuntime.ValidateMemoization inputs={t10} output={items_0} />;
let t8;
if ($[20] !== items_0 || $[21] !== t7) {
t8 = <SharedRuntime.ValidateMemoization inputs={t7} output={items_0} />;
$[20] = items_0;
$[21] = t10;
$[22] = t11;
$[21] = t7;
$[22] = t8;
} else {
t11 = $[22];
t8 = $[22];
}
let t12;
if ($[23] !== t11 || $[24] !== t7 || $[25] !== t9) {
t12 = (
let t9;
if ($[23] !== t4 || $[24] !== t6 || $[25] !== t8) {
t9 = (
<>
{t7}
{t9}
{t11}
{t4}
{t6}
{t8}
</>
);
$[23] = t11;
$[24] = t7;
$[25] = t9;
$[26] = t12;
$[23] = t4;
$[24] = t6;
$[25] = t8;
$[26] = t9;
} else {
t12 = $[26];
t9 = $[26];
}
return t12;
return t9;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -51,28 +51,23 @@ export function Component(t0) {
const $ = _c(27);
const { a, b } = t0;
let t1;
let t2;
if ($[0] !== a) {
t2 = { a };
t1 = { a };
$[0] = a;
$[1] = t2;
$[1] = t1;
} else {
t2 = $[1];
t1 = $[1];
}
t1 = t2;
const item1 = t1;
let t3;
let t4;
let t2;
if ($[2] !== b) {
t4 = { b };
t2 = { b };
$[2] = b;
$[3] = t4;
$[3] = t2;
} else {
t4 = $[3];
t2 = $[3];
}
t3 = t4;
const item2 = t3;
let t5;
const item2 = t2;
let items;
if ($[4] !== item1 || $[5] !== item2) {
items = [];
@@ -84,77 +79,76 @@ export function Component(t0) {
} else {
items = $[6];
}
t5 = items;
const items_0 = t5;
let t6;
const items_0 = items;
let t3;
if ($[7] !== a) {
t6 = [a];
t3 = [a];
$[7] = a;
$[8] = t6;
$[8] = t3;
} else {
t6 = $[8];
t3 = $[8];
}
let t4;
if ($[9] !== items_0[0] || $[10] !== t3) {
t4 = <ValidateMemoization inputs={t3} output={items_0[0]} />;
$[9] = items_0[0];
$[10] = t3;
$[11] = t4;
} else {
t4 = $[11];
}
let t5;
if ($[12] !== b) {
t5 = [b];
$[12] = b;
$[13] = t5;
} else {
t5 = $[13];
}
let t6;
if ($[14] !== items_0[1] || $[15] !== t5) {
t6 = <ValidateMemoization inputs={t5} output={items_0[1]} />;
$[14] = items_0[1];
$[15] = t5;
$[16] = t6;
} else {
t6 = $[16];
}
let t7;
if ($[9] !== items_0[0] || $[10] !== t6) {
t7 = <ValidateMemoization inputs={t6} output={items_0[0]} />;
$[9] = items_0[0];
$[10] = t6;
$[11] = t7;
} else {
t7 = $[11];
}
let t8;
if ($[12] !== b) {
t8 = [b];
$[12] = b;
$[13] = t8;
} else {
t8 = $[13];
}
let t9;
if ($[14] !== items_0[1] || $[15] !== t8) {
t9 = <ValidateMemoization inputs={t8} output={items_0[1]} />;
$[14] = items_0[1];
$[15] = t8;
$[16] = t9;
} else {
t9 = $[16];
}
let t10;
if ($[17] !== a || $[18] !== b) {
t10 = [a, b];
t7 = [a, b];
$[17] = a;
$[18] = b;
$[19] = t10;
$[19] = t7;
} else {
t10 = $[19];
t7 = $[19];
}
let t11;
if ($[20] !== items_0 || $[21] !== t10) {
t11 = <ValidateMemoization inputs={t10} output={items_0} />;
let t8;
if ($[20] !== items_0 || $[21] !== t7) {
t8 = <ValidateMemoization inputs={t7} output={items_0} />;
$[20] = items_0;
$[21] = t10;
$[22] = t11;
$[21] = t7;
$[22] = t8;
} else {
t11 = $[22];
t8 = $[22];
}
let t12;
if ($[23] !== t11 || $[24] !== t7 || $[25] !== t9) {
t12 = (
let t9;
if ($[23] !== t4 || $[24] !== t6 || $[25] !== t8) {
t9 = (
<>
{t7}
{t9}
{t11}
{t4}
{t6}
{t8}
</>
);
$[23] = t11;
$[24] = t7;
$[25] = t9;
$[26] = t12;
$[23] = t4;
$[24] = t6;
$[25] = t8;
$[26] = t9;
} else {
t12 = $[26];
t9 = $[26];
}
return t12;
return t9;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -70,34 +70,32 @@ function Inner(props) {
const $ = _c(7);
const input = use(FooContext);
let t0;
let t1;
if ($[0] !== input) {
t1 = [input];
t0 = [input];
$[0] = input;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const output = t0;
let t2;
let t1;
if ($[2] !== input) {
t2 = [input];
t1 = [input];
$[2] = input;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
let t3;
if ($[4] !== output || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={output} />;
let t2;
if ($[4] !== output || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={output} />;
$[4] = output;
$[5] = t2;
$[6] = t3;
$[5] = t1;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -86,34 +86,32 @@ function Inner(props) {
input;
let t0;
let t1;
if ($[0] !== input) {
t1 = [input];
t0 = [input];
$[0] = input;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const output = t0;
let t2;
let t1;
if ($[2] !== input) {
t2 = [input];
t1 = [input];
$[2] = input;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
let t3;
if ($[4] !== output || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={output} />;
let t2;
if ($[4] !== output || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={output} />;
$[4] = output;
$[5] = t2;
$[6] = t3;
$[5] = t1;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -72,34 +72,32 @@ function Inner(props) {
const $ = _c(7);
const input = React.use(FooContext);
let t0;
let t1;
if ($[0] !== input) {
t1 = [input];
t0 = [input];
$[0] = input;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
t0 = t1;
const output = t0;
let t2;
let t1;
if ($[2] !== input) {
t2 = [input];
t1 = [input];
$[2] = input;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
let t3;
if ($[4] !== output || $[5] !== t2) {
t3 = <ValidateMemoization inputs={t2} output={output} />;
let t2;
if ($[4] !== output || $[5] !== t1) {
t2 = <ValidateMemoization inputs={t1} output={output} />;
$[4] = output;
$[5] = t2;
$[6] = t3;
$[5] = t1;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
return t3;
return t2;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -37,23 +37,21 @@ import { useEffect } from "react";
function someGlobal() {}
function useFoo() {
const $ = _c(2);
const fn = _temp;
let t0;
t0 = _temp;
const fn = t0;
let t1;
let t2;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = () => {
t0 = () => {
fn();
};
t2 = [fn];
$[0] = t1;
$[1] = t2;
t1 = [fn];
$[0] = t0;
$[1] = t1;
} else {
t1 = $[0];
t2 = $[1];
t0 = $[0];
t1 = $[1];
}
useEffect(t1, t2);
useEffect(t0, t1);
return null;
}
function _temp() {

View File

@@ -37,23 +37,21 @@ import * as React from "react";
function someGlobal() {}
function useFoo() {
const $ = _c(2);
const fn = _temp;
let t0;
t0 = _temp;
const fn = t0;
let t1;
let t2;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = () => {
t0 = () => {
fn();
};
t2 = [fn];
$[0] = t1;
$[1] = t2;
t1 = [fn];
$[0] = t0;
$[1] = t1;
} else {
t1 = $[0];
t2 = $[1];
t0 = $[0];
t1 = $[1];
}
React.useEffect(t1, t2);
React.useEffect(t0, t1);
return null;
}
function _temp() {

View File

@@ -21,45 +21,43 @@ import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(10);
let t0;
let t1;
if ($[0] !== props.a) {
t1 = makeObject(props.a);
t0 = makeObject(props.a);
$[0] = props.a;
$[1] = t1;
$[1] = t0;
} else {
t1 = $[1];
t0 = $[1];
}
const a = t1;
let t2;
const a = t0;
let t1;
if ($[2] !== props.b) {
t2 = makeObject(props.b);
t1 = makeObject(props.b);
$[2] = props.b;
$[3] = t2;
$[3] = t1;
} else {
t2 = $[3];
t1 = $[3];
}
const b = t2;
let t3;
const b = t1;
let t2;
if ($[4] !== a || $[5] !== b) {
t3 = [a, b];
t2 = [a, b];
$[4] = a;
$[5] = b;
$[6] = t3;
$[6] = t2;
} else {
t3 = $[6];
t2 = $[6];
}
t0 = t3;
const [a_0, b_0] = t0;
let t4;
const [a_0, b_0] = t2;
let t3;
if ($[7] !== a_0 || $[8] !== b_0) {
t4 = [a_0, b_0];
t3 = [a_0, b_0];
$[7] = a_0;
$[8] = b_0;
$[9] = t4;
$[9] = t3;
} else {
t4 = $[9];
t3 = $[9];
}
return t4;
return t3;
}
```

View File

@@ -23,10 +23,7 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t0;
t0 = props.value;
const x = t0;
const x = props.value;
return x;
}

View File

@@ -19,9 +19,7 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t0;
t0 = props.a && props.b;
const x = t0;
const x = props.a && props.b;
return x;
}

View File

@@ -51,13 +51,11 @@ function Component(props) {
const part = free2.part;
useHook();
let t0;
const x = makeObject_Primitives();
x.value = props.value;
mutate(x, free, part);
t0 = x;
const object = t0;
const object = x;
identity(free);
identity(part);

View File

@@ -71,7 +71,6 @@ function Component(props) {
const part = free2.part;
useHook();
let t2;
let x;
if ($[2] !== props.value) {
x = makeObject_Primitives();
@@ -82,8 +81,7 @@ function Component(props) {
} else {
x = $[3];
}
t2 = x;
const object = t2;
const object = x;
identity(free);
identity(part);

View File

@@ -27,18 +27,14 @@ import { useMemo } from "react";
import { identity, makeObject_Primitives, mutate } from "shared-runtime";
function Component(props) {
const $ = _c(2);
let t0;
const $ = _c(1);
let object;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = makeObject_Primitives();
object = t0;
object = makeObject_Primitives();
identity(object);
$[0] = object;
$[1] = t0;
} else {
object = $[0];
t0 = $[1];
}
return object;
}

View File

@@ -29,14 +29,12 @@ import { identity, makeObject_Primitives, mutate } from "shared-runtime";
function Component(props) {
const $ = _c(1);
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t1 = makeObject_Primitives();
$[0] = t1;
t0 = makeObject_Primitives();
$[0] = t0;
} else {
t1 = $[0];
t0 = $[0];
}
t0 = t1;
const object = t0;
identity(object);
return object;

View File

@@ -24,12 +24,10 @@ export const FIXTURE_ENTRYPOINT = {
```javascript
function Component(props) {
let t0;
if (props.cond) {
if (props.cond) {
}
}
t0 = undefined;
}
export const FIXTURE_ENTRYPOINT = {

View File

@@ -15,10 +15,7 @@ function component(a) {
```javascript
function component(a) {
let t0;
mutate(a);
t0 = undefined;
}
```

Some files were not shown because too many files have changed in this diff Show More