1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

allow multiple defers

This commit is contained in:
Alexander Medvednikov 2019-07-21 16:34:21 +02:00
parent 5d188130e5
commit ac238a5362
2 changed files with 2 additions and 1 deletions

View File

@ -3439,7 +3439,7 @@ fn (p mut Parser) defer_st() {
p.check(.lcbr)
p.genln('{')
p.statements()
p.cur_fn.defer_text = p.cgen.lines.right(pos).join('\n')
p.cur_fn.defer_text = p.cgen.lines.right(pos).join('\n') + p.cur_fn.defer_text
p.genln('*/')
}

View File

@ -6,6 +6,7 @@ fn foo() string {
fn foo2() string {
println('start')
defer { println('defer') }
defer { println('defer2') }
println('end')
return foo()
}