mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: check that functions return in all if/else branches
This commit is contained in:

committed by
Alexander Medvednikov

parent
28147c0930
commit
61983a6799
@@ -2928,6 +2928,8 @@ fn (p mut Parser) if_st(is_expr bool, elif_depth int) string {
|
||||
else {
|
||||
typ = p.statements()
|
||||
}
|
||||
if_returns := p.returns
|
||||
p.returns = false
|
||||
// println('IF TYp=$typ')
|
||||
if p.tok == .key_else {
|
||||
p.fgenln('')
|
||||
@@ -2959,6 +2961,8 @@ fn (p mut Parser) if_st(is_expr bool, elif_depth int) string {
|
||||
}
|
||||
return typ
|
||||
}
|
||||
else_returns := p.returns
|
||||
p.returns = if_returns && else_returns
|
||||
p.inside_if_expr = false
|
||||
if p.fileis('test_test') {
|
||||
println('if ret typ="$typ" line=$p.scanner.line_nr')
|
||||
|
Reference in New Issue
Block a user