mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
parser: add return dropping to false to check whether statements return
This commit is contained in:
parent
5c43bfbf13
commit
c6f7479a72
1 changed files with 19 additions and 12 deletions
|
@ -3400,7 +3400,11 @@ fn (p mut Parser) match_statement(is_expr bool) string {
|
|||
|
||||
return res_typ
|
||||
} else {
|
||||
p.match_parse_statement_branch()
|
||||
p.returns = false
|
||||
p.check(.lcbr)
|
||||
|
||||
p.genln('{ ')
|
||||
p.statements()
|
||||
p.returns = all_cases_return && p.returns
|
||||
return ''
|
||||
}
|
||||
|
@ -3427,8 +3431,14 @@ fn (p mut Parser) match_statement(is_expr bool) string {
|
|||
|
||||
return res_typ
|
||||
} else {
|
||||
p.returns = false
|
||||
p.genln('else // default:')
|
||||
p.match_parse_statement_branch()
|
||||
|
||||
p.check(.lcbr)
|
||||
|
||||
p.genln('{ ')
|
||||
p.statements()
|
||||
|
||||
p.returns = all_cases_return && p.returns
|
||||
return ''
|
||||
}
|
||||
|
@ -3507,11 +3517,15 @@ fn (p mut Parser) match_statement(is_expr bool) string {
|
|||
p.gen(')')
|
||||
}
|
||||
else {
|
||||
p.match_parse_statement_branch()
|
||||
p.returns = false
|
||||
p.check(.lcbr)
|
||||
|
||||
p.genln('{ ')
|
||||
p.statements()
|
||||
|
||||
all_cases_return = all_cases_return && p.returns
|
||||
// p.gen(')')
|
||||
}
|
||||
|
||||
all_cases_return = all_cases_return && p.returns
|
||||
i++
|
||||
}
|
||||
|
||||
|
@ -3525,13 +3539,6 @@ fn (p mut Parser) match_statement(is_expr bool) string {
|
|||
return ''
|
||||
}
|
||||
|
||||
fn (p mut Parser) match_parse_statement_branch(){
|
||||
p.check(.lcbr)
|
||||
|
||||
p.genln('{ ')
|
||||
p.statements()
|
||||
}
|
||||
|
||||
fn (p mut Parser) assert_statement() {
|
||||
if p.first_pass() {
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue