Files
oxc-project__oxc/crates/oxc_react_compiler/fixtures/try-catch-unused-throwing-value.js
Boshen 2fe0a0dfd4 fix(react_compiler): preserve caught property loads (#25498)
Preserve catch-observable property and computed loads during dead-code elimination, and record their root operands as reactive-scope dependencies so throwing reads remain inside `try`.

This prevents memoization from suppressing catch behavior or hoisting potentially throwing property access into cache guards.

Validated with the React Compiler crate suite, NAPI transform suite, and original-vs-compiled runtime cases.

AI assistance was used to investigate and implement this change.
2026-08-11 07:15:55 +00:00

23 lines
445 B
JavaScript

// @compilationMode:annotation
function Component({count, maybe}) {
'use memo';
const value = {count};
try {
const unused = maybe.item;
value.count++;
} catch {
value.count += 10;
}
return value.count;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{count: 1, maybe: null}],
sequentialRenders: [
{count: 1, maybe: null},
{count: 1, maybe: null},
{count: 1, maybe: {item: 'ok'}},
],
};