From 0d9ac1f59cd43d0ba6f51fcf06e2b4c29d7e8cc1 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 21 Aug 2022 21:19:39 +0800 Subject: [PATCH] checker: improve error message for test function definition (#15483) --- vlib/v/checker/fn.v | 2 +- .../v/checker/tests/test_functions_wrong_signature_test.out | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 7c31ee2a15..0725817f1e 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -309,7 +309,7 @@ fn (mut c Checker) fn_decl(mut node ast.FnDecl) { if node.return_type != ast.void_type_idx && node.return_type.clear_flag(.optional) != ast.void_type_idx && node.return_type.clear_flag(.result) != ast.void_type_idx { - c.error('test functions should either return nothing at all, or be marked to return `?`', + c.error('test functions should either return nothing at all, or be marked to return `?` or `!`', node.pos) } } diff --git a/vlib/v/checker/tests/test_functions_wrong_signature_test.out b/vlib/v/checker/tests/test_functions_wrong_signature_test.out index e0f1404e86..b544f0aa09 100644 --- a/vlib/v/checker/tests/test_functions_wrong_signature_test.out +++ b/vlib/v/checker/tests/test_functions_wrong_signature_test.out @@ -1,12 +1,12 @@ -vlib/v/checker/tests/test_functions_wrong_signature_test.vv:9:1: error: test functions should either return nothing at all, or be marked to return `?` - 7 | +vlib/v/checker/tests/test_functions_wrong_signature_test.vv:9:1: error: test functions should either return nothing at all, or be marked to return `?` or `!` + 7 | 8 | // should be disallowed: 9 | fn test_returning_int() int { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 10 | } 11 | vlib/v/checker/tests/test_functions_wrong_signature_test.vv:19:1: error: test functions should take 0 parameters - 17 | + 17 | 18 | // should be disallowed: 19 | fn test_take_parameters(v int) { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~