mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
e3683f29d8
Materializes identifier reads before compound-assignment binary operations so constant propagation matches the upstream React Compiler. AI-assisted.
28 lines
571 B
Plaintext
28 lines
571 B
Plaintext
---
|
|
source: crates/oxc_react_compiler/tests/snapshot.rs
|
|
input_file: crates/oxc_react_compiler/fixtures/constant-propagation-compound-assignment.tsx
|
|
---
|
|
import { c as _c } from "react/compiler-runtime";
|
|
function Component(t0) {
|
|
const $ = _c(3);
|
|
const { suffix, offset } = t0;
|
|
let text = "prefix";
|
|
let count = 10;
|
|
if (suffix) {
|
|
text = "prefix" + suffix;
|
|
}
|
|
if (offset) {
|
|
count = 10 - offset;
|
|
}
|
|
let t1;
|
|
if ($[0] !== count || $[1] !== text) {
|
|
t1 = <div>{text}: {count}</div>;
|
|
$[0] = count;
|
|
$[1] = text;
|
|
$[2] = t1;
|
|
} else {
|
|
t1 = $[2];
|
|
}
|
|
return t1;
|
|
}
|