Skip to content

Commit a65de77

Browse files
committed
[compiler] Add repro for func properties bug with gating
When gating is enabled, any function declaration properties that were previously set (typically `Function.displayName`) would cause a crash after compilation as the original identifier is no longer present. ghstack-source-id: beb7e25 Pull Request resolved: #29802
1 parent a0a435d commit a65de77

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
## Input
3+
4+
```javascript
5+
// @gating
6+
7+
/**
8+
* Fail: bug-gating-invalid-function-properties
9+
* Unexpected error in Forget runner
10+
* Component is not defined
11+
*/
12+
export default function Component() {
13+
return <></>;
14+
}
15+
16+
export function Component2() {
17+
return <></>;
18+
}
19+
20+
Component.displayName = "Component ONE";
21+
Component2.displayName = "Component TWO";
22+
23+
export const FIXTURE_ENTRYPOINT = {
24+
fn: Component,
25+
params: [],
26+
sequentialRenders: [],
27+
};
28+
29+
```
30+
31+
## Code
32+
33+
```javascript
34+
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
35+
import { c as _c } from "react/compiler-runtime"; // @gating
36+
37+
/**
38+
* Fail: bug-gating-invalid-function-properties
39+
* Unexpected error in Forget runner
40+
* Component is not defined
41+
*/
42+
export default isForgetEnabled_Fixtures()
43+
? function Component() {
44+
const $ = _c(1);
45+
let t0;
46+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
47+
t0 = <></>;
48+
$[0] = t0;
49+
} else {
50+
t0 = $[0];
51+
}
52+
return t0;
53+
}
54+
: function Component() {
55+
return <></>;
56+
};
57+
58+
export const Component2 = isForgetEnabled_Fixtures()
59+
? function Component2() {
60+
const $ = _c(1);
61+
let t0;
62+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
63+
t0 = <></>;
64+
$[0] = t0;
65+
} else {
66+
t0 = $[0];
67+
}
68+
return t0;
69+
}
70+
: function Component2() {
71+
return <></>;
72+
};
73+
74+
Component.displayName = "Component ONE";
75+
Component2.displayName = "Component TWO";
76+
77+
export const FIXTURE_ENTRYPOINT = {
78+
fn: Component,
79+
params: [],
80+
sequentialRenders: [],
81+
};
82+
83+
```
84+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// @gating
2+
3+
/**
4+
* Fail: bug-gating-invalid-function-properties
5+
* Unexpected error in Forget runner
6+
* Component is not defined
7+
*/
8+
export default function Component() {
9+
return <></>;
10+
}
11+
12+
export function Component2() {
13+
return <></>;
14+
}
15+
16+
Component.displayName = "Component ONE";
17+
Component2.displayName = "Component TWO";
18+
19+
export const FIXTURE_ENTRYPOINT = {
20+
fn: Component,
21+
params: [],
22+
sequentialRenders: [],
23+
};

compiler/packages/snap/src/SproutTodoFilter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ const skipFilter = new Set([
490490
"bug-invalid-hoisting-functionexpr",
491491
"original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block",
492492
"original-reactive-scopes-fork/bug-hoisted-declaration-with-scope",
493+
"bug-gating-invalid-function-properties",
493494

494495
// 'react-compiler-runtime' not yet supported
495496
"flag-enable-emit-hook-guards",

0 commit comments

Comments
 (0)