Skip to content

Commit 2a9274a

Browse files
committed
[compiler] Repro: updates to globals should be retained
ghstack-source-id: 7ee813c0d72e3c752b299f63bfcec3647b022544 Pull Request resolved: #30470
1 parent e215aa1 commit 2a9274a

File tree

5 files changed

+111
-0
lines changed

5 files changed

+111
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
## Input
3+
4+
```javascript
5+
let renderCount = 0;
6+
function useFoo() {
7+
renderCount += 1;
8+
return renderCount;
9+
}
10+
11+
export const FIXTURE_ENTRYPOINT = {
12+
fn: useFoo,
13+
params: [],
14+
};
15+
16+
```
17+
18+
## Code
19+
20+
```javascript
21+
let renderCount = 0;
22+
function useFoo() {
23+
return renderCount;
24+
}
25+
26+
export const FIXTURE_ENTRYPOINT = {
27+
fn: useFoo,
28+
params: [],
29+
};
30+
31+
```
32+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let renderCount = 0;
2+
function useFoo() {
3+
renderCount += 1;
4+
return renderCount;
5+
}
6+
7+
export const FIXTURE_ENTRYPOINT = {
8+
fn: useFoo,
9+
params: [],
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
## Input
3+
4+
```javascript
5+
import {Stringify} from 'shared-runtime';
6+
7+
let renderCount = 0;
8+
function Foo() {
9+
const cb = () => {
10+
renderCount += 1;
11+
return renderCount;
12+
};
13+
return <Stringify cb={cb} shouldInvokeFns={true} />;
14+
}
15+
16+
export const FIXTURE_ENTRYPOINT = {
17+
fn: Foo,
18+
params: [{}],
19+
};
20+
21+
```
22+
23+
## Code
24+
25+
```javascript
26+
import { c as _c } from "react/compiler-runtime";
27+
import { Stringify } from "shared-runtime";
28+
29+
let renderCount = 0;
30+
function Foo() {
31+
const $ = _c(1);
32+
const cb = _temp;
33+
let t0;
34+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
35+
t0 = <Stringify cb={cb} shouldInvokeFns={true} />;
36+
$[0] = t0;
37+
} else {
38+
t0 = $[0];
39+
}
40+
return t0;
41+
}
42+
function _temp() {
43+
return renderCount;
44+
}
45+
46+
export const FIXTURE_ENTRYPOINT = {
47+
fn: Foo,
48+
params: [{}],
49+
};
50+
51+
```
52+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {Stringify} from 'shared-runtime';
2+
3+
let renderCount = 0;
4+
function Foo() {
5+
const cb = () => {
6+
renderCount += 1;
7+
return renderCount;
8+
};
9+
return <Stringify cb={cb} shouldInvokeFns={true} />;
10+
}
11+
12+
export const FIXTURE_ENTRYPOINT = {
13+
fn: Foo,
14+
params: [{}],
15+
};

compiler/packages/snap/src/SproutTodoFilter.ts

+2
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ const skipFilter = new Set([
484484
'rules-of-hooks/rules-of-hooks-69521d94fa03',
485485

486486
// bugs
487+
'bug-invalid-update-global-should-bailout',
488+
'bug-update-global-in-callback',
487489
'bug-invalid-hoisting-functionexpr',
488490
'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block',
489491
'original-reactive-scopes-fork/bug-hoisted-declaration-with-scope',

0 commit comments

Comments
 (0)