[test] Add test for lambda that shadows ref
There is no ref captured as it is shadowed and the lambda does not depend on the ref.
Sathya Gunasekaran committed
Mar 8, 2023 at 00:15 UTC
1e8b6b51d3b315803c809071e52a7d733f6dbc1b
2 files changed
+44
compiler/forget/src/__tests__/fixtures/hir/capturing-function-shadow-captured.expect.md
new
+36
@@ -0,0 +1,36 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function component(a) {
6
+ let z = { a };
7
+ let x = function () {
8
+ let z;
9
+ mutate(z);
10
+ };
11
+ return x;
12
+}
13
+
14
+```
15
+
16
+## Code
17
+
18
+```javascript
19
+function component(a) {
20
+ const $ = React.unstable_useMemoCache(1);
21
+ let t0;
22
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
23
+ t0 = function () {
24
+ let z;
25
+ mutate(z);
26
+ };
27
+ $[0] = t0;
28
+ } else {
29
+ t0 = $[0];
30
+ }
31
+ const x = t0;
32
+ return x;
33
+}
34
+
35
+```
36
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/capturing-function-shadow-captured.js
new
+8
@@ -0,0 +1,8 @@
1
+function component(a) {
2
+ let z = { a };
3
+ let x = function () {
4
+ let z;
5
+ mutate(z);
6
+ };
7
+ return x;
8
+}