diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.expect.md new file mode 100644 index 0000000000..9d33267161 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.expect.md @@ -0,0 +1,31 @@ + +## Input + +```javascript +function Component(props) { + let x = foo(props.a?.b.c.d); + return x; +} + +``` + +## Code + +```javascript +function Component(props) { + const $ = React.unstable_useMemoCache(2); + const c_0 = $[0] !== props.a.b.c.d; + let t0; + if (c_0) { + t0 = foo(props.a?.b?.c?.d); + $[0] = props.a.b.c.d; + $[1] = t0; + } else { + t0 = $[1]; + } + const x = t0; + return x; +} + +``` + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.js b/compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.js new file mode 100644 index 0000000000..63561f207c --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.nested-optional-member-expr.js @@ -0,0 +1,4 @@ +function Component(props) { + let x = foo(props.a?.b.c.d); + return x; +} diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.primitive-computed-load.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.primitive-computed-load.expect.md new file mode 100644 index 0000000000..7886b720d0 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.primitive-computed-load.expect.md @@ -0,0 +1,35 @@ + +## Input + +```javascript +function Component(props) { + let a = foo(); + // freeze `a` so we know the next line cannot mutate it +