aboutsummaryrefslogtreecommitdiff
path: root/lib/Parser/ParserFile.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-07-26 19:15:54 +0000
committer_ov4 <ov4@ov4.org>2026-07-26 19:15:54 +0000
commit3818460a473bd3ffcd35f09eb6429e1b0f00bc07 (patch)
tree5b75e70d56e6c23e8446f76232b7c00b4b65a354 /lib/Parser/ParserFile.cc
parentc2c2e1771bf9b747f38dc145b5201b45c579d465 (diff)
fix: top-level RETURN and READFILE designator targets error cleanly
- RETURN outside any FUNCTION/PROCEDURE used to emit an i64/void ret inside i32 main — a verifier dump instead of a diagnostic. It is now a clean compile error (no signature means top level: pseudocode cannot name a function 'main', it is a reserved runtime symbol). - READFILE "f.txt", r.f mis-parsed into an error cascade the same way INPUT r.f did before its fix; the target now consumes the designator and reports one clear 'must be a plain STRING variable' error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'lib/Parser/ParserFile.cc')
-rw-r--r--lib/Parser/ParserFile.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Parser/ParserFile.cc b/lib/Parser/ParserFile.cc
index 6fd368c..4a4ae31 100644
--- a/lib/Parser/ParserFile.cc
+++ b/lib/Parser/ParserFile.cc
@@ -57,6 +57,14 @@ std::unique_ptr<StmtAST> Parser::ParseReadFile() {
std::string VarName = Lex.IdentifierStr;
getNextToken(); // eat the variable name
+ if (CurTok == '[' || CurTok == '.' || CurTok == '^') {
+ // Consume the whole designator so it cannot replay as statements.
+ std::vector<DesignatorAccess> Dummy;
+ ParseDesignatorSuffix(Dummy);
+ fprintf(stderr, "Error: READFILE target must be a plain STRING variable at line %d\n", Line);
+ return nullptr;
+ }
+
return std::make_unique<ReadFileStmtAST>(std::move(FileName), VarName, Line);
}