[storelocal] lvalues are always const
Joe Savona committed
Mar 2, 2023 at 14:19 UTC
f4abf0a9ee43daf880bda8bbcd66a0a86e8d6f42
1 file changed
+6
-5
compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts
+6
-5
@@ -493,6 +493,12 @@ function codegenInstruction(
493
cx.temp.set(instr.lvalue.place.identifier.id, value);
494
return t.emptyStatement();
495
} else {
496
+ if (instr.lvalue.kind !== InstructionKind.Const) {
497
+ CompilerError.invariant(
498
+ `Expected all instruction lvalues to be const declarations`,
499
+ instr.lvalue.place.loc
500
+ );
501
+ }
502
const kind = cx.hasDeclared(instr.lvalue.place.identifier)
503
? InstructionKind.Reassign
504
: instr.lvalue.kind;
@@ -502,11 +508,6 @@ function codegenInstruction(
508
t.variableDeclarator(codegenLVal(instr.lvalue), value),
509
]);
510
}
505
- case InstructionKind.Let: {
506
- return createVariableDeclaration(instr.loc, "let", [
507
- t.variableDeclarator(codegenLVal(instr.lvalue), value),
508
- ]);
509
- }
511
case InstructionKind.Reassign: {
512
return createExpressionStatement(
513
instr.loc,