From 759a7e027b814ab4982b25974d93abbbbcf9286a Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Mon, 13 Feb 2023 16:52:08 -0500 Subject: [PATCH] Fix incorrectly recording declarations in reassignments in PropagateScopeDependencies This was incorrectly added in #1190, oops! --- .../PropagateScopeDependencies.ts | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts index 87a711acdf..4a08286b9d 100644 --- a/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts +++ b/compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts @@ -380,14 +380,16 @@ function visitInstruction(context: Context, instr: ReactiveInstruction): void { if (lvalue == null) { return; } - context.visitReassignment(lvalue); - // TODO: only assign Const if the value is never reassigned - const kind = context.isReactive(lvalue.place.identifier) - ? DeclKind.Dynamic - : DeclKind.Const; - context.declare(lvalue.place.identifier, { - kind, - id: lvalue.place.identifier.mutableRange.start, - scope: context.currentScope, - }); + if (lvalue.kind === InstructionKind.Reassign) { + context.visitReassignment(lvalue); + } else { + const kind = context.isReactive(lvalue.place.identifier) + ? DeclKind.Dynamic + : DeclKind.Const; + context.declare(lvalue.place.identifier, { + kind, + id: lvalue.place.identifier.mutableRange.start, + scope: context.currentScope, + }); + } }