From e717664c749cf237479147ddecd70a39fc3426f2 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 03:52:21 +0000 Subject: refactor(codegen): share writable variable lookup emitLValue (variable and designator base) and plain assignment repeated the same lookup, enum-or-unknown diagnostic and requireWritable check. Move it into a private lookupWritableSymbol helper. READFILE keeps its own lookup, which has no enum diagnostic. Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/StatementGen.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'lib/CodeGen/StatementGen.cc') diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc index f4cd661..c1a9490 100644 --- a/lib/CodeGen/StatementGen.cc +++ b/lib/CodeGen/StatementGen.cc @@ -152,16 +152,8 @@ void CodeGen::emitStmtImpl(StmtAST *Stmt) { } if (auto *Assign = dynamic_cast(Stmt)) { - const SymbolInfo *Info = getSymbolInfo(Assign->getName()); - if (!Info) { - if (Types->lookupEnumConstant(Assign->getName())) { - reportError("Enum value %s is not an assignable location", Assign->getName().c_str()); - } else { - reportError("Unknown variable name %s", Assign->getName().c_str()); - } - return; - } - if (!requireWritable(*Info, Assign->getName())) return; + const SymbolInfo *Info = lookupWritableSymbol(Assign->getName()); + if (!Info) return; if (Info->IsArray) { reportError("Cannot assign array %s without indices", Assign->getName().c_str()); return; -- cgit v1.3.1-4-g156e