parser: fix match/else check

pull/6112/head
Alexander Medvednikov 2020-08-11 17:30:37 +02:00
parent c5aa2bfa51
commit 99798b83b4
1 changed files with 3 additions and 2 deletions

View File

@ -152,7 +152,8 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
p.next()
var_name = p.check_name()
}
if p.tok.kind == .lcbr {
no_lcbr := p.tok.kind != .lcbr
if !no_lcbr {
p.check(.lcbr)
}
mut branches := []ast.MatchBranch{}
@ -258,7 +259,7 @@ fn (mut p Parser) match_expr() ast.MatchExpr {
post_comments: post_comments
}
p.close_scope()
if p.tok.kind == .rcbr || is_else {
if p.tok.kind == .rcbr || (is_else && no_lcbr) {
break
}
}