mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 08:54:25 +00:00
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:
parent
84693aa655
commit
a5f417100d
5 changed files with 289 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue