From f4abf0a9ee43daf880bda8bbcd66a0a86e8d6f42 Mon Sep 17 00:00:00 2001 From: Joe Savona Date: Thu, 2 Mar 2023 14:19:17 -0800 Subject: [PATCH] [storelocal] lvalues are always const --- .../src/ReactiveScopes/CodegenReactiveFunction.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts index daae03b26b..e8eddd0509 100644 --- a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -493,6 +493,12 @@ function codegenInstruction( cx.temp.set(instr.lvalue.place.identifier.id, value); return t.emptyStatement(); } else { + if (instr.lvalue.kind !== InstructionKind.Const) { + CompilerError.invariant( + `Expected all instruction lvalues to be const declarations`, + instr.lvalue.place.loc + ); + } const kind = cx.hasDeclared(instr.lvalue.place.identifier) ? InstructionKind.Reassign : instr.lvalue.kind; @@ -502,11 +508,6 @@ function codegenInstruction( t.variableDeclarator(codegenLVal(instr.lvalue), value), ]); } - case InstructionKind.Let: { - return createVariableDeclaration(instr.loc, "let", [ - t.variableDeclarator(codegenLVal(instr.lvalue), value), - ]); - } case InstructionKind.Reassign: { return createExpressionStatement( instr.loc,