File tree Expand file tree Collapse file tree 3 files changed +83
-2
lines changed
compiler/packages/babel-plugin-react-compiler/src
__tests__/fixtures/compiler Expand file tree Collapse file tree 3 files changed +83
-2
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
34
34
} from "../HIR/HIR" ;
35
35
import { FunctionSignature } from "../HIR/ObjectShape" ;
36
36
import {
37
+ printFunction ,
37
38
printIdentifier ,
38
39
printMixedHIR ,
39
40
printPlace ,
@@ -201,7 +202,7 @@ export default function inferReferenceEffects(
201
202
let queuedState = queuedStates . get ( blockId ) ;
202
203
if ( queuedState != null ) {
203
204
// merge the queued states for this block
204
- state = queuedState . merge ( state ) ?? state ;
205
+ state = queuedState . merge ( state ) ?? queuedState ;
205
206
queuedStates . set ( blockId , state ) ;
206
207
} else {
207
208
/*
@@ -765,7 +766,7 @@ class InferenceState {
765
766
result . values [ id ] = { kind, value : printMixedHIR ( value ) } ;
766
767
}
767
768
for ( const [ variable , values ] of this . #variables) {
768
- result . variables [ variable ] = [ ...values ] . map ( identify ) ;
769
+ result . variables [ `$ ${ variable } ` ] = [ ...values ] . map ( identify ) ;
769
770
}
770
771
return result ;
771
772
}
Original file line number Diff line number Diff line change
1
+
2
+ ## Input
3
+
4
+ ``` javascript
5
+ import { arrayPush } from " shared-runtime" ;
6
+
7
+ function Foo (cond ) {
8
+ let x = null ;
9
+ if (cond) {
10
+ x = [];
11
+ } else {
12
+ }
13
+ // Here, x = phi(x$null, x$[]) does not receive the correct ValueKind
14
+ arrayPush (x, 2 );
15
+
16
+ return x;
17
+ }
18
+
19
+ export const FIXTURE_ENTRYPOINT = {
20
+ fn: Foo,
21
+ params: [{ cond: true }],
22
+ sequentialRenders: [{ cond: true }, { cond: true }],
23
+ };
24
+
25
+ ```
26
+
27
+ ## Code
28
+
29
+ ``` javascript
30
+ import { c as _c } from " react/compiler-runtime" ;
31
+ import { arrayPush } from " shared-runtime" ;
32
+
33
+ function Foo (cond ) {
34
+ const $ = _c (2 );
35
+ let x;
36
+ if ($[0 ] !== cond) {
37
+ x = null ;
38
+ if (cond) {
39
+ x = [];
40
+ }
41
+
42
+ arrayPush (x, 2 );
43
+ $[0 ] = cond;
44
+ $[1 ] = x;
45
+ } else {
46
+ x = $[1 ];
47
+ }
48
+ return x;
49
+ }
50
+
51
+ export const FIXTURE_ENTRYPOINT = {
52
+ fn: Foo,
53
+ params: [{ cond: true }],
54
+ sequentialRenders: [{ cond: true }, { cond: true }],
55
+ };
56
+
57
+ ```
58
+
59
+ ### Eval output
60
+ (kind: ok) [ 2]
61
+ [ 2]
Original file line number Diff line number Diff line change
1
+ import { arrayPush } from "shared-runtime" ;
2
+
3
+ function Foo ( cond ) {
4
+ let x = null ;
5
+ if ( cond ) {
6
+ x = [ ] ;
7
+ } else {
8
+ }
9
+ // Here, x = phi(x$null, x$[]) does not receive the correct ValueKind
10
+ arrayPush ( x , 2 ) ;
11
+
12
+ return x ;
13
+ }
14
+
15
+ export const FIXTURE_ENTRYPOINT = {
16
+ fn : Foo ,
17
+ params : [ { cond : true } ] ,
18
+ sequentialRenders : [ { cond : true } , { cond : true } ] ,
19
+ } ;
You can’t perform that action at this time.
0 commit comments