boot: errors as values (-> T!, error(), try, or, fallible builtins and main)

A function that can fail returns { ok, value, message }. return error(...) makes
the failure; try passes it on after running the defers; 'or <value>' and
'or { ... err ... }' handle it. int(text), float(text), read_file, write_file
and delete_file report failure to an enclosing or/try instead of stopping the
program. fn main() -> ! prints the error and exits with 1.

boot.sh: 15 passed, 0 failed, 7 skipped.
This commit is contained in:
Nexoniarz 2026-10-25 18:50:29 +01:00
commit a5f417100d
5 changed files with 289 additions and 18 deletions

View file

@ -78,7 +78,8 @@ struct Node {
str recv // fn Point.move(...): "Point"; empty for a plain function
str text // literal text
Type ty // declared type (decl, param, field, fn result)
bool flag // decl: has a type; fn: has a body
bool flag // decl: has a type; or: the right side is a { block }
bool fallible // fn: -> T! or -> !
[]Node kids
[]str names // named arguments: Point(x: 1)
int line