diff --git a/compiler/forget/src/__tests__/fixtures/hir/capturing-var-in-nested-func-decl.expect.md b/compiler/forget/src/__tests__/fixtures/hir/capturing-var-in-nested-func-decl.expect.md new file mode 100644 index 0000000000..fb87164eb9 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/hir/capturing-var-in-nested-func-decl.expect.md @@ -0,0 +1,57 @@ + +## Input + +```javascript +function component(a) { + let z = { a }; + let x = function () { + function t() { + z; + } + t(); + }; + return x; +} + +``` + +## Code + +```javascript +function component(a) { + const $ = React.useMemoCache(); + const c_0 = $[0] !== a; + let z; + if (c_0) { + z = { + a: a, + }; + $[0] = a; + $[1] = z; + } else { + z = $[1]; + } + + const c_2 = $[2] !== z; + let x; + + if (c_2) { + x = function () { + function t() { + z; + } + + t(); + }; + + $[2] = z; + $[3] = x; + } else { + x = $[3]; + } + + return x; +} + +``` + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/hir/capturing-var-in-nested-func-decl.js b/compiler/forget/src/__tests__/fixtures/hir/capturing-var-in-nested-func-decl.js new file mode 100644 index 0000000000..c600600ca4 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/hir/capturing-var-in-nested-func-decl.js @@ -0,0 +1,10 @@ +function component(a) { + let z = { a }; + let x = function () { + function t() { + z; + } + t(); + }; + return x; +}