mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[storelocal] lvalues are always const
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user