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 return res_typ
} else { } else {
p.match_parse_statement_branch() p.returns = false
p.check(.lcbr)
p.genln('{ ')
p.statements()
p.returns = all_cases_return && p.returns p.returns = all_cases_return && p.returns
return '' return ''
} }
@ -3427,8 +3431,14 @@ fn (p mut Parser) match_statement(is_expr bool) string {
return res_typ return res_typ
} else { } else {
p.returns = false
p.genln('else // default:') p.genln('else // default:')
p.match_parse_statement_branch()
p.check(.lcbr)
p.genln('{ ')
p.statements()
p.returns = all_cases_return && p.returns p.returns = all_cases_return && p.returns
return '' return ''
} }
@ -3507,11 +3517,15 @@ fn (p mut Parser) match_statement(is_expr bool) string {
p.gen(')') p.gen(')')
} }
else { 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(')') // p.gen(')')
} }
all_cases_return = all_cases_return && p.returns
i++ i++
} }
@ -3525,13 +3539,6 @@ fn (p mut Parser) match_statement(is_expr bool) string {
return '' return ''
} }
fn (p mut Parser) match_parse_statement_branch(){
p.check(.lcbr)
p.genln('{ ')
p.statements()
}
fn (p mut Parser) assert_statement() { fn (p mut Parser) assert_statement() {
if p.first_pass() { if p.first_pass() {
return return