[rhir] Visit DoWhile's test as a conditional dependency
Missed this in the prior PR!
Lauren Tan committed
Mar 3, 2023 at 00:31 UTC
0ad0f8cf43f25e47d7aae4b43cfba388a9a48e80
2 files changed
+5
-3
compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+3
-1
@@ -576,7 +576,9 @@ function visit(context: Context, block: ReactiveBlock): void {
576
}
577
case "do-while": {
578
visit(context, terminal.loop);
579
- visitReactiveValue(context, terminal.id, terminal.test);
579
+ context.enterConditional(() => {
580
+ visitReactiveValue(context, terminal.id, terminal.test);
581
+ });
582
break;
583
}
584
case "while": {
compiler/forget/src/__tests__/fixtures/hir/do-while-conditional-break.expect.md
+2
-2
@@ -20,7 +20,7 @@ function Component(props) {
20
```javascript
21
function Component(props) {
22
const $ = React.unstable_useMemoCache(2);
23
- const c_0 = $[0] !== props.cond;
23
+ const c_0 = $[0] !== props;
24
let x;
25
if (c_0) {
26
x = [0, 1, 2, 3];
@@ -31,7 +31,7 @@ function Component(props) {
31
32
mutate(x);
33
} while (props.cond);
34
- $[0] = props.cond;
34
+ $[0] = props;
35
$[1] = x;
36
} else {
37
x = $[1];