From 0ad0f8cf43f25e47d7aae4b43cfba388a9a48e80 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Fri, 3 Mar 2023 00:31:37 -0500 Subject: [PATCH] [rhir] Visit DoWhile's test as a conditional dependency Missed this in the prior PR! --- .../forget/src/ReactiveScopes/PropagateScopeDependencies.ts | 4 +++- .../fixtures/hir/do-while-conditional-break.expect.md | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts index 135617af57..5505ce1487 100644 --- a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts +++ b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts @@ -576,7 +576,9 @@ function visit(context: Context, block: ReactiveBlock): void { } case "do-while": { visit(context, terminal.loop); - visitReactiveValue(context, terminal.id, terminal.test); + context.enterConditional(() => { + visitReactiveValue(context, terminal.id, terminal.test); + }); break; } case "while": { diff --git a/compiler/forget/src/__tests__/fixtures/hir/do-while-conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/hir/do-while-conditional-break.expect.md index f2759479b8..33d9099030 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/do-while-conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/do-while-conditional-break.expect.md @@ -20,7 +20,7 @@ function Component(props) { ```javascript function Component(props) { const $ = React.unstable_useMemoCache(2); - const c_0 = $[0] !== props.cond; + const c_0 = $[0] !== props; let x; if (c_0) { x = [0, 1, 2, 3]; @@ -31,7 +31,7 @@ function Component(props) { mutate(x); } while (props.cond); - $[0] = props.cond; + $[0] = props; $[1] = x; } else { x = $[1];