parser: autofree - reset p.branch_parent_pos to previous pos on return

pull/7162/head
joe-conigliaro 2020-12-06 17:00:44 +11:00
parent aeb467e038
commit d7c057840a
No known key found for this signature in database
GPG Key ID: C12F7136C08206F1
2 changed files with 7 additions and 0 deletions

View File

@ -9,7 +9,11 @@ import v.table
fn (mut p Parser) for_stmt() ast.Stmt { fn (mut p Parser) for_stmt() ast.Stmt {
p.check(.key_for) p.check(.key_for)
pos := p.tok.position() pos := p.tok.position()
prev_branch_parent_pos := p.branch_parent_pos
p.branch_parent_pos = pos.pos p.branch_parent_pos = pos.pos
defer {
p.branch_parent_pos = prev_branch_parent_pos
}
p.open_scope() p.open_scope()
p.inside_for = true p.inside_for = true
if p.tok.kind == .key_match { if p.tok.kind == .key_match {

View File

@ -275,6 +275,9 @@ fn free_before_break() {
for { for {
cc := [7, 8, 9] cc := [7, 8, 9]
if true { if true {
if true {
break
}
break break
} }
} }