From ab1c265679749401b3c9aa2ebb5d1f4c5b8a1ca9 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 2 May 2022 22:40:17 +0300 Subject: [PATCH] builtin: add missing panic_result_not_set/1 callback function. --- vlib/builtin/builtin.c.v | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vlib/builtin/builtin.c.v b/vlib/builtin/builtin.c.v index bb0442cd0b..5091e88de6 100644 --- a/vlib/builtin/builtin.c.v +++ b/vlib/builtin/builtin.c.v @@ -64,12 +64,20 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) { 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] pub fn panic_optional_not_set(s string) { 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. // It also shows a backtrace on most platforms. [noreturn]