mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
ecab5f7d2b
Removes synthetic expression statements emitted after captured compound assignments when their value is unused. The lowering-created context load is tagged so analysis retains it, while codegen can omit it after the lvalue is pruned. Consumed assignment results are preserved. Validated with `env -u NO_COLOR just ready`. AI assistance: Codex was used to investigate, implement, and validate this change.
29 lines
612 B
Plaintext
29 lines
612 B
Plaintext
---
|
|
source: crates/oxc_react_compiler/tests/snapshot.rs
|
|
input_file: crates/oxc_react_compiler/fixtures/compound-assignment-context-result.js
|
|
---
|
|
import { c as _c } from "react/compiler-runtime";
|
|
function Component(t0) {
|
|
const $ = _c(2);
|
|
const { values } = t0;
|
|
let count;
|
|
if ($[0] !== values) {
|
|
count = 0;
|
|
values.forEach((value) => {
|
|
count = count + value;
|
|
count = count + value;
|
|
const result = count;
|
|
console.log(result);
|
|
});
|
|
$[0] = values;
|
|
$[1] = count;
|
|
} else {
|
|
count = $[1];
|
|
}
|
|
return count;
|
|
}
|
|
export const FIXTURE_ENTRYPOINT = {
|
|
fn: Component,
|
|
params: [{ values: [1, 2] }]
|
|
};
|