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];