mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: process defer
statement
This commit is contained in:
parent
9d61f4fad1
commit
b1ea908b3b
@ -138,6 +138,11 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
|
|||||||
f.indent--
|
f.indent--
|
||||||
f.writeln(')\n')
|
f.writeln(')\n')
|
||||||
}
|
}
|
||||||
|
ast.DeferStmt {
|
||||||
|
f.writeln('defer {')
|
||||||
|
f.stmts(it.stmts)
|
||||||
|
f.writeln('}')
|
||||||
|
}
|
||||||
ast.ExprStmt {
|
ast.ExprStmt {
|
||||||
f.expr(it.expr)
|
f.expr(it.expr)
|
||||||
if !f.single_line_if {
|
if !f.single_line_if {
|
||||||
|
@ -83,6 +83,12 @@ fn get_user_ptr() &User {
|
|||||||
return &User{}
|
return &User{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fn_with_defer() {
|
||||||
|
defer {
|
||||||
|
close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
field1 int
|
field1 int
|
||||||
field2 string
|
field2 string
|
||||||
|
@ -88,6 +88,11 @@ fn get_user_ptr() & User {
|
|||||||
return &User{}
|
return &User{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fn_with_defer() {
|
||||||
|
defer { close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
field1 int
|
field1 int
|
||||||
field2 string
|
field2 string
|
||||||
|
Loading…
Reference in New Issue
Block a user