mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: check missing return values in functions (#5803)
This commit is contained in:
parent
37d739684c
commit
9b4c81e85f
@ -3060,7 +3060,7 @@ fn (c &Checker) fetch_and_verify_orm_fields(info table.Struct, pos token.Positio
|
||||
}
|
||||
|
||||
fn (mut c Checker) fn_decl(mut node ast.FnDecl) {
|
||||
c.returns = true
|
||||
c.returns = false
|
||||
if node.is_generic && c.cur_generic_type == 0 { // need the cur_generic_type check to avoid inf. recursion
|
||||
// loop thru each generic type and generate a function
|
||||
for gen_type in c.table.fn_gen_types[node.name] {
|
||||
|
5
vlib/v/checker/tests/function_missing_return_type.out
Normal file
5
vlib/v/checker/tests/function_missing_return_type.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/function_missing_return_type.v:1:1: error: missing return at end of function `h`
|
||||
1 | fn h() int {
|
||||
| ~~~~~~~~~~
|
||||
2 | }
|
||||
3 |
|
7
vlib/v/checker/tests/function_missing_return_type.vv
Normal file
7
vlib/v/checker/tests/function_missing_return_type.vv
Normal file
@ -0,0 +1,7 @@
|
||||
fn h() int {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
d := h()
|
||||
println('$d')
|
||||
}
|
Loading…
Reference in New Issue
Block a user