diff options
| author | _ov4 <ov4@ov4.org> | 2026-07-26 12:51:55 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-07-26 12:51:55 +0000 |
| commit | d1c47a328785ece9a8ffd9bbca3138818b8203b3 (patch) | |
| tree | 5a057e73674f6d7ac021572007266706fecc31fd /lib/Parser | |
| parent | 9164871fe4982bdd12866eb28ebded68ca3dacd1 (diff) | |
fix: close correctness gaps found by post-refactor adversarial review
Confirmed by a 17-agent review pass over the refactor diff (12 findings
verified against the code and reproduced end-to-end):
- marshalCallArgs: BYREF arguments must match the declared parameter
type exactly (was: silent bit-reinterpretation, e.g. REAL passed to
BYREF INTEGER printed garbage with exit 0); whole-array arguments are
rejected (was: callee assignment smashed the array data pointer ->
runtime SIGSEGV)
- Null guards for CHR/LCASE/UCASE/IS_NUM/NUM_TO_STR/STR_TO_NUM/ASC
argument emission (was: compiler SIGSEGV on e.g. CHR(undeclared)),
matching the guards MID/RIGHT/LEFT already had
- ParseReturnStmt: propagate expression-parse failure (was: diagnostic
printed but exit 0) and recognize bare RETURN before
ENDWHILE/UNTIL/NEXT (was: bogus diagnostic on legal early return)
- emitPrototype rejects FUNCTION/PROCEDURE names that collide with
runtime/libc symbols (was: FUNCTION strlen silently hijacked the
string runtime; arity mismatch crashed createArgumentAllocas) or with
builtins (was: silently shadowed); conflicting redefinitions keep the
first signature
- FOR STEP is evaluated exactly once, before the loop (was: once per
iteration; the runtime-direction refactor had moved it to N+1)
- RETURN values are coerced to the declared return type via the
signature table (RETURN n in a RETURNS REAL function now compiles)
- '&' coerces its operands to STRING (CHAR/number operands work);
OUTPUT of a PROCEDURE call reports a clean error
AGENTS docs updated to match. All positive samples remain byte-identical
to the pre-refactor baseline.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'lib/Parser')
| -rw-r--r-- | lib/Parser/ParserFunction.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Parser/ParserFunction.cc b/lib/Parser/ParserFunction.cc index 6ce0b8e..7663f38 100644 --- a/lib/Parser/ParserFunction.cc +++ b/lib/Parser/ParserFunction.cc @@ -137,8 +137,12 @@ std::unique_ptr<StmtAST> Parser::ParseCallStmt() { std::unique_ptr<StmtAST> Parser::ParseReturnStmt() { getNextToken(); std::unique_ptr<ExprAST> Expr = nullptr; - if (CurTok != tok_endif && CurTok != tok_else && CurTok != tok_endfunction && CurTok != tok_endprocedure) { + // A bare RETURN is recognized right before any block terminator. + if (CurTok != tok_endif && CurTok != tok_else && CurTok != tok_endfunction && + CurTok != tok_endprocedure && CurTok != tok_endwhile && CurTok != tok_until && + CurTok != tok_next && CurTok != tok_eof) { Expr = ParseExpression(); + if (!Expr) return nullptr; } return std::make_unique<ReturnStmtAST>(std::move(Expr)); } |
