Fix incorrectly recording declarations in reassignments in PropagateScopeDependencies
Fix incorrectly recording declarations in reassignments in PropagateScopeDependencies This was incorrectly added in #1190, oops!
Lauren Tan committed
Feb 13, 2023 at 16:52 UTC
759a7e027b814ab4982b25974d93abbbbcf9286a
1 file changed
+12
-10
compiler/forget/src/ReactiveScopes/PropagateScopeDependencies.ts
+12
-10
@@ -380,14 +380,16 @@ function visitInstruction(context: Context, instr: ReactiveInstruction): void {
380
if (lvalue == null) {
381
return;
382
}
383
- context.visitReassignment(lvalue);
384
- // TODO: only assign Const if the value is never reassigned
385
- const kind = context.isReactive(lvalue.place.identifier)
386
- ? DeclKind.Dynamic
387
- : DeclKind.Const;
388
- context.declare(lvalue.place.identifier, {
389
- kind,
390
- id: lvalue.place.identifier.mutableRange.start,
391
- scope: context.currentScope,
392
- });
383
+ if (lvalue.kind === InstructionKind.Reassign) {
384
+ context.visitReassignment(lvalue);
385
+ } else {
386
+ const kind = context.isReactive(lvalue.place.identifier)
387
+ ? DeclKind.Dynamic
388
+ : DeclKind.Const;
389
+ context.declare(lvalue.place.identifier, {
390
+ kind,
391
+ id: lvalue.place.identifier.mutableRange.start,
392
+ scope: context.currentScope,
393
+ });
394
+ }
395
}