1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: improve error message for test function definition (#15483)

This commit is contained in:
yuyi 2022-08-21 21:19:39 +08:00 committed by GitHub
parent f194d3ca2e
commit 0d9ac1f59c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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)
}
}

View File

@ -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) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~