[test case] Failing assignment inside of nested if statement
``` function useBar(props) { let z; if (props.a) { if (props.b) { z = baz(); } } return z; } ``` Currently fails with ``` InvariantViolation: A phi cannot have two operands initialized before its declaration ```
mofeiZ committed
Jan 31, 2023 at 16:53 UTC
5fbfce6d3b0ffc0b61cecacd028263608725024e
2 files changed
+37
compiler/forget/src/__tests__/fixtures/hir/error.assignment-in-nested-if.expect.md
new
+26
@@ -0,0 +1,26 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+function useBar(props) {
6
+ let z;
7
+
8
+ if (props.a) {
9
+ if (props.b) {
10
+ z = baz();
11
+ }
12
+ }
13
+
14
+ return z;
15
+}
16
+
17
+```
18
+
19
+
20
+## Error
21
+
22
+```
23
+A phi cannot have two operands initialized before its declaration
24
+```
25
+
26
+
\ No newline at end of file
compiler/forget/src/__tests__/fixtures/hir/error.assignment-in-nested-if.js
new
+11
@@ -0,0 +1,11 @@
1
+function useBar(props) {
2
+ let z;
3
+
4
+ if (props.a) {
5
+ if (props.b) {
6
+ z = baz();
7
+ }
8
+ }
9
+
10
+ return z;
11
+}