[storelocal] lvalues are always const

This commit is contained in:
Joe Savona
2023-03-02 14:19:17 -08:00
parent 487786f7d4
commit f4abf0a9ee
@@ -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,