1
0
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:
Julian Schurhammer
2019-08-08 19:49:56 +12:00
committed by Alexander Medvednikov
parent 28147c0930
commit 61983a6799
9 changed files with 14 additions and 2 deletions

View File

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