diff --git a/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts b/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts index f39cde96e9..5ee700aa6a 100644 --- a/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts +++ b/compiler/forget/src/ReactiveScopes/InferReactiveIdentifiers.ts @@ -10,7 +10,6 @@ import { Identifier, ReactiveFunction, ReactiveInstruction, - ReactiveScope, } from "../HIR/HIR"; import { parseHookCall } from "../Inference/InferReferenceEffects"; import { @@ -118,21 +117,8 @@ export function inferReactiveIdentifiers( for (const param of fn.params) { reactivityMap.set(param.identifier, true); } - const actuallyReactiveScopes = new Set(); - visitReactiveFunction(fn, visitor, reactivityMap); - for (const [id, value] of reactivityMap) { - const { scope } = id; - if (value && scope != null) { - actuallyReactiveScopes.add(scope); - } - } - for (const [id, _] of reactivityMap) { - if (id.scope && actuallyReactiveScopes.has(id.scope)) { - reactivityMap.set(id, true); - } - } const result = new Set(); reactivityMap.forEach((isReactive, id) => { if (isReactive) result.add(id); diff --git a/compiler/forget/src/ReactiveScopes/PruneNonReactiveDependencies.ts b/compiler/forget/src/ReactiveScopes/PruneNonReactiveDependencies.ts index c3c1449b10..8adaf70698 100644 --- a/compiler/forget/src/ReactiveScopes/PruneNonReactiveDependencies.ts +++ b/compiler/forget/src/ReactiveScopes/PruneNonReactiveDependencies.ts @@ -31,11 +31,16 @@ class Visitor extends ReactiveFunctionVisitor { scope.scope.dependencies.delete(dep); } } - // If a scope now has no dependencies, then its declarations are all non-reactive if (scope.scope.dependencies.size === 0) { + // If a scope has no dependencies, then its declarations are all non-reactive for (const [, declaration] of scope.scope.declarations) { state.delete(declaration); } + } else { + // otherwise, all the scope's declarations are reactive + for (const [, declaration] of scope.scope.declarations) { + state.add(declaration); + } } } }