Repro for nested method calls causing promoted property load invariant
Joe Savona committed
Mar 21, 2024 at 14:11 UTC
0e72e2a00e9644801fa2fab2142e60f7076bfc0c
2 files changed
+45
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.expect.md
new
+33
@@ -0,0 +1,33 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+import { makeArray } from "shared-runtime";
6
+
7
+function Component(props) {
8
+ const items = makeArray(0, 1, 2, null, 4, false, 6);
9
+ const max = Math.max(...items.filter(Boolean));
10
+ return max;
11
+}
12
+
13
+export const FIXTURE_ENTRYPOINT = {
14
+ fn: Component,
15
+ params: [{}],
16
+};
17
+
18
+```
19
+
20
+
21
+## Error
22
+
23
+```
24
+ 3 | function Component(props) {
25
+ 4 | const items = makeArray(0, 1, 2, null, 4, false, 6);
26
+> 5 | const max = Math.max(...items.filter(Boolean));
27
+ | ^^^^^^^^ [ReactForget] Invariant: [Codegen] Internal error: MethodCall::property must be an unpromoted + unmemoized MemberExpression. Got a 'Identifier' (5:5)
28
+ 6 | return max;
29
+ 7 | }
30
+ 8 |
31
+```
32
+
33
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-nested-method-calls-lower-property-load-into-temporary.js
new
+12
@@ -0,0 +1,12 @@
1
+import { makeArray } from "shared-runtime";
2
+
3
+function Component(props) {
4
+ const items = makeArray(0, 1, 2, null, 4, false, 6);
5
+ const max = Math.max(...items.filter(Boolean));
6
+ return max;
7
+}
8
+
9
+export const FIXTURE_ENTRYPOINT = {
10
+ fn: Component,
11
+ params: [{}],
12
+};