mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
2fe0a0dfd4
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.
23 lines
445 B
JavaScript
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'}},
|
|
],
|
|
};
|