@samitouri / QOS-React / commits / 50640a1b88

[compiler][repro] Test fixture for fbt whitespace bug

ghstack-source-id: 749feb2cb8026858b4c01a7405272a56c7bc382b Pull Request resolved: https://github.com/facebook/react/pull/30394

Mofei Zhang committed Jul 23, 2024 at 14:17 UTC 50640a1b884c8ab656c1cb0626bbbf5f39a574b7
3 files changed +133
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/bug-fbt-preserve-whitespace-param.expect.md new
+100
@@ -0,0 +1,100 @@
1 +
2 +## Input
3 +
4 +```javascript
5 +import fbt from 'fbt';
6 +
7 +/**
8 + * Currently fails with the following:
9 + * Found differences in evaluator results
10 + * Non-forget (expected):
11 + * (kind: ok) <div><span>Jason !</span></div>
12 + * Forget:
13 + * (kind: ok) <div><span>Jason!</span></div>
14 +
15 + */
16 +
17 +function Foo(props) {
18 + return (
19 + // prettier-ignore
20 + <div>
21 + <fbt desc={"Dialog to show to user"}>
22 + <span>
23 + <fbt:param name="user name">
24 + {props.name}
25 + </fbt:param>
26 + !
27 + </span>
28 + </fbt>
29 + </div>
30 + );
31 +}
32 +
33 +export const FIXTURE_ENTRYPOINT = {
34 + fn: Foo,
35 + params: [{name: 'Jason'}],
36 +};
37 +
38 +```
39 +
40 +## Code
41 +
42 +```javascript
43 +import { c as _c } from "react/compiler-runtime";
44 +import fbt from "fbt";
45 +
46 +/**
47 + * Currently fails with the following:
48 + * Found differences in evaluator results
49 + * Non-forget (expected):
50 + * (kind: ok) <div><span>Jason !</span></div>
51 + * Forget:
52 + * (kind: ok) <div><span>Jason!</span></div>
53 +
54 + */
55 +
56 +function Foo(props) {
57 + const $ = _c(2);
58 + let t0;
59 + if ($[0] !== props.name) {
60 + t0 = (
61 + <div>
62 + {fbt._(
63 + "{=m0}",
64 + [
65 + fbt._implicitParam(
66 + "=m0",
67 + <span>
68 + {fbt._(
69 + "{user name}!",
70 + [
71 + fbt._param(
72 + "user name",
73 +
74 + props.name,
75 + ),
76 + ],
77 + { hk: "mBBZ9" },
78 + )}
79 + </span>,
80 + ),
81 + ],
82 + { hk: "3RVfuk" },
83 + )}
84 + </div>
85 + );
86 + $[0] = props.name;
87 + $[1] = t0;
88 + } else {
89 + t0 = $[1];
90 + }
91 + return t0;
92 +}
93 +
94 +export const FIXTURE_ENTRYPOINT = {
95 + fn: Foo,
96 + params: [{ name: "Jason" }],
97 +};
98 +
99 +```
100 +
\ No newline at end of file
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/bug-fbt-preserve-whitespace-param.tsx new
+32
@@ -0,0 +1,32 @@
1 +import fbt from 'fbt';
2 +
3 +/**
4 + * Currently fails with the following:
5 + * Found differences in evaluator results
6 + * Non-forget (expected):
7 + * (kind: ok) <div><span>Jason !</span></div>
8 + * Forget:
9 + * (kind: ok) <div><span>Jason!</span></div>
10 +
11 + */
12 +
13 +function Foo(props) {
14 + return (
15 + // prettier-ignore
16 + <div>
17 + <fbt desc={"Dialog to show to user"}>
18 + <span>
19 + <fbt:param name="user name">
20 + {props.name}
21 + </fbt:param>
22 + !
23 + </span>
24 + </fbt>
25 + </div>
26 + );
27 +}
28 +
29 +export const FIXTURE_ENTRYPOINT = {
30 + fn: Foo,
31 + params: [{name: 'Jason'}],
32 +};
compiler/packages/snap/src/SproutTodoFilter.ts
+1
@@ -484,6 +484,7 @@ const skipFilter = new Set([
484 'rules-of-hooks/rules-of-hooks-69521d94fa03',
485
486 // bugs
487 + 'fbt/bug-fbt-preserve-whitespace-param',
488 'bug-invalid-hoisting-functionexpr',
489 'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block',
490 'original-reactive-scopes-fork/bug-hoisted-declaration-with-scope',