Skip to content

Commit cf44a8c

Browse files
committed
[compiler][repro] Test fixture for fbt plural bug
ghstack-source-id: d0c6a4e Pull Request resolved: #30432
1 parent b34b750 commit cf44a8c

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
## Input
3+
4+
```javascript
5+
import fbt from 'fbt';
6+
7+
/**
8+
* Forget + fbt inconsistency. Evaluator errors with the following
9+
* Found differences in evaluator results
10+
* Non-forget (expected):
11+
* (kind: ok) 1 rewrite to Rust · 2 months traveling
12+
* Forget:
13+
* (kind: ok) 1 rewrites to Rust · 2 months traveling
14+
*/
15+
function Foo({rewrites, months}) {
16+
return (
17+
<fbt desc="Test fbt description">
18+
<fbt:plural count={rewrites} name="number of rewrites" showCount="yes">
19+
rewrite
20+
</fbt:plural>
21+
to Rust ·
22+
<fbt:plural count={months} name="number of months" showCount="yes">
23+
month
24+
</fbt:plural>
25+
traveling
26+
</fbt>
27+
);
28+
}
29+
30+
export const FIXTURE_ENTRYPOINT = {
31+
fn: Foo,
32+
params: [{rewrites: 1, months: 2}],
33+
};
34+
35+
```
36+
37+
## Code
38+
39+
```javascript
40+
import { c as _c } from "react/compiler-runtime";
41+
import fbt from "fbt";
42+
43+
/**
44+
* Forget + fbt inconsistency. Evaluator errors with the following
45+
* Found differences in evaluator results
46+
* Non-forget (expected):
47+
* (kind: ok) 1 rewrite to Rust · 2 months traveling
48+
* Forget:
49+
* (kind: ok) 1 rewrites to Rust · 2 months traveling
50+
*/
51+
function Foo(t0) {
52+
const $ = _c(3);
53+
const { rewrites, months } = t0;
54+
let t1;
55+
if ($[0] !== rewrites || $[1] !== months) {
56+
t1 = fbt._(
57+
{
58+
"*": {
59+
"*": "{number of rewrites} rewrites to Rust · {number of months} months traveling",
60+
},
61+
_1: { _1: "1 rewrite to Rust · 1 month traveling" },
62+
},
63+
[
64+
fbt._plural(rewrites, "number of rewrites"),
65+
fbt._plural(months, "number of months"),
66+
],
67+
{ hk: "49MfZA" },
68+
);
69+
$[0] = rewrites;
70+
$[1] = months;
71+
$[2] = t1;
72+
} else {
73+
t1 = $[2];
74+
}
75+
return t1;
76+
}
77+
78+
export const FIXTURE_ENTRYPOINT = {
79+
fn: Foo,
80+
params: [{ rewrites: 1, months: 2 }],
81+
};
82+
83+
```
84+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import fbt from 'fbt';
2+
3+
/**
4+
* Forget + fbt inconsistency. Evaluator errors with the following
5+
* Found differences in evaluator results
6+
* Non-forget (expected):
7+
* (kind: ok) 1 rewrite to Rust · 2 months traveling
8+
* Forget:
9+
* (kind: ok) 1 rewrites to Rust · 2 months traveling
10+
*/
11+
function Foo({rewrites, months}) {
12+
return (
13+
<fbt desc="Test fbt description">
14+
<fbt:plural count={rewrites} name="number of rewrites" showCount="yes">
15+
rewrite
16+
</fbt:plural>
17+
to Rust ·
18+
<fbt:plural count={months} name="number of months" showCount="yes">
19+
month
20+
</fbt:plural>
21+
traveling
22+
</fbt>
23+
);
24+
}
25+
26+
export const FIXTURE_ENTRYPOINT = {
27+
fn: Foo,
28+
params: [{rewrites: 1, months: 2}],
29+
};

compiler/packages/snap/src/SproutTodoFilter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ const skipFilter = new Set([
484484
'rules-of-hooks/rules-of-hooks-69521d94fa03',
485485

486486
// bugs
487+
'fbt/bug-multiple-fbt-plural',
487488
'fbt/bug-fbt-preserve-whitespace-param',
488489
'bug-invalid-hoisting-functionexpr',
489490
'original-reactive-scopes-fork/bug-nonmutating-capture-in-unsplittable-memo-block',

0 commit comments

Comments
 (0)