parser: add return dropping to false to check whether statements return

pull/1866/head
Danil-Lapirow 2019-09-04 19:48:01 +03:00 committed by Alexander Medvednikov
parent 5c43bfbf13
commit c6f7479a72
1 changed files with 19 additions and 12 deletions

View File

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