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
|
|
@ -24,7 +24,7 @@ fn isHex(char c) -> bool {
|
|||
|
||||
fn isKeyword(str w) -> bool {
|
||||
keywords := ["fn", "return", "if", "else", "while", "for", "in", "break", "continue", "true", "false",
|
||||
"null", "import", "link", "struct", "defer"]
|
||||
"null", "import", "link", "struct", "defer", "or", "try"]
|
||||
return keywords.contains(w)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue