checker: check missing return values in functions (#5803)
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] {
|
||||
|
|
|
@ -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 |
|
|
@ -0,0 +1,7 @@
|
|||
fn h() int {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
d := h()
|
||||
println('$d')
|
||||
}
|
Loading…
Reference in New Issue