Skip to content

Commit 1fb72df

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: 7a7ad23 Pull Request resolved: #29802
1 parent 0a5e0b0 commit 1fb72df

File tree

3 files changed

+81
-0
lines changed

3 files changed

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

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)