builtin: add missing panic_result_not_set/1 callback function.

master
Delyan Angelov 2022-05-02 22:40:17 +03:00
parent db185598d2
commit ab1c265679
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 9 additions and 1 deletions

View File

@ -64,12 +64,20 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
vhalt() vhalt()
} }
// panic_optional_not_set prints given optional not set and exits the process // panic_optional_not_set is called by V, when you use option error propagation in your main function.
// It ends the program with a panic.
[noreturn] [noreturn]
pub fn panic_optional_not_set(s string) { pub fn panic_optional_not_set(s string) {
panic('optional not set ($s)') panic('optional not set ($s)')
} }
// panic_optional_not_set is called by V, when you use result error propagation in your main function
// It ends the program with a panic.
[noreturn]
pub fn panic_result_not_set(s string) {
panic('result not set ($s)')
}
// panic prints a nice error message, then exits the process with exit code of 1. // panic prints a nice error message, then exits the process with exit code of 1.
// It also shows a backtrace on most platforms. // It also shows a backtrace on most platforms.
[noreturn] [noreturn]