From 4588bb44abf87d70b046bac3b78f0cad5fdb5f0f Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 6 Aug 2022 10:24:17 +0300 Subject: [PATCH] markused: skip panic_result_not_set (generated for `fn main(){ foo()! }`) too --- vlib/v/markused/markused.v | 1 + ...hands_for_optionals_and_results_in_main.run.out | 2 ++ ...tionals_and_results_in_main.skip_unused.run.out | 2 ++ ...shorthands_for_optionals_and_results_in_main.vv | 14 ++++++++++++++ 4 files changed, 19 insertions(+) create mode 100644 vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.run.out create mode 100644 vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.skip_unused.run.out create mode 100644 vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.vv diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index a8b00782ac..5ed906565c 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -244,6 +244,7 @@ pub fn mark_used(mut table ast.Table, pref &pref.Preferences, ast_files []&ast.F all_fn_root_names << 'panic_debug' } all_fn_root_names << 'panic_optional_not_set' + all_fn_root_names << 'panic_result_not_set' if pref.is_test { all_fn_root_names << 'main.cb_assertion_ok' all_fn_root_names << 'main.cb_assertion_failed' diff --git a/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.run.out b/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.run.out new file mode 100644 index 0000000000..daaac9e303 --- /dev/null +++ b/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.run.out @@ -0,0 +1,2 @@ +42 +42 diff --git a/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.skip_unused.run.out b/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.skip_unused.run.out new file mode 100644 index 0000000000..daaac9e303 --- /dev/null +++ b/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.skip_unused.run.out @@ -0,0 +1,2 @@ +42 +42 diff --git a/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.vv b/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.vv new file mode 100644 index 0000000000..b61f70407f --- /dev/null +++ b/vlib/v/tests/skip_unused/shorthands_for_optionals_and_results_in_main.vv @@ -0,0 +1,14 @@ +fn opt() ?int { + return 42 +} + +fn result() !int { + return 42 +} + +fn main() { + o := opt()? + r := result()! + println(o) + println(r) +}