diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.ssa-reassign-in-rval.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.ssa-reassign-in-rval.expect.md new file mode 100644 index 0000000000..a25e1e4212 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.ssa-reassign-in-rval.expect.md @@ -0,0 +1,44 @@ + +## Input + +```javascript +// Forget should call the original x (x = foo()) to compute result +function Component() { + let x = foo(); + let result = x((x = bar()), 5); + return [result, x]; +} + +``` + +## Code + +```javascript +// Forget should call the original x (x = foo()) to compute result +function Component() { + const $ = React.unstable_useMemoCache(3); + let t0; + let x; + if ($[0] === Symbol.for("react.memo_cache_sentinel")) { + x = foo(); + x = bar(); + t0 = x(x, 5); + $[0] = t0; + $[1] = x; + } else { + t0 = $[0]; + x = $[1]; + } + const result = t0; + let t1; + if ($[2] === Symbol.for("react.memo_cache_sentinel")) { + t1 = [result, x]; + $[2] = t1; + } else { + t1 = $[2]; + } + return t1; +} + +``` + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.ssa-reassign-in-rval.js b/compiler/forget/src/__tests__/fixtures/compiler/_bug.ssa-reassign-in-rval.js new file mode 100644 index 0000000000..9126165e59 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.ssa-reassign-in-rval.js @@ -0,0 +1,6 @@ +// Forget should call the original x (x = foo()) to compute result +function Component() { + let x = foo(); + let result = x((x = bar()), 5); + return [result, x]; +}