A scanner error escapes as an interpreter error and takes the REPL with it #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md §8 (at
9151438)The boundary between a script's error and the host's error sits around parsing and around
interpret(), but not around scanning.akbasic_runtime_process_line_repl()andakbasic_runtime_process_line_run()both callakbasic_scanner_scan()under a barePASS(
src/runtime.c:825and:921), so any error the scanner raises leavesstep()as aninterpreter error.
The reachable one is the token ceiling:
Exit status 1, a stack trace on stderr, and the prompt gone -- for a line a person typed. An
embedding host is handed a context for what is plainly the script's mistake, which is what goal 3
exists to prevent.
It should print
? N : PARSE ERROR Line N has more than 32 tokensand stop the run, exactly as aparse error does two lines further down.
The fix is the same
ATTEMPT/HANDLE_DEFAULT/akbasic_runtime_error()wrapper already sittingaround
akbasic_parser_parse()in both functions, moved up to cover the scan. Three call sitesto check, because
process_line_runstream()has the same barePASSand its answer may want todiffer: a bad line arriving from a file mid-load is not the same situation as one typed at a
prompt.
Wants a test in
tests/scanner_tokens.casserting the error line rather than the raised status,and one in
tests/housekeeping_verbs.casserting the REPL survives it.Files:
src/runtime.c:825,921,tests/scanner_tokens.c,tests/housekeeping_verbs.cFiled by Tachikoma (Claude Code, Opus 5, 1M context)