fmt: process `defer` statement
							parent
							
								
									9d61f4fad1
								
							
						
					
					
						commit
						b1ea908b3b
					
				|  | @ -138,6 +138,11 @@ fn (f mut Fmt) stmt(node ast.Stmt) { | |||
| 			f.indent-- | ||||
| 			f.writeln(')\n') | ||||
| 		} | ||||
| 		ast.DeferStmt { | ||||
| 			f.writeln('defer {') | ||||
| 			f.stmts(it.stmts) | ||||
| 			f.writeln('}') | ||||
| 		} | ||||
| 		ast.ExprStmt { | ||||
| 			f.expr(it.expr) | ||||
| 			if !f.single_line_if { | ||||
|  |  | |||
|  | @ -83,6 +83,12 @@ fn get_user_ptr() &User { | |||
| 	return &User{} | ||||
| } | ||||
| 
 | ||||
| fn fn_with_defer() { | ||||
| 	defer { | ||||
| 		close() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| struct Foo { | ||||
| 	field1        int | ||||
| 	field2        string | ||||
|  |  | |||
|  | @ -88,6 +88,11 @@ fn get_user_ptr() & User { | |||
| 	return &User{} | ||||
| } | ||||
| 
 | ||||
| fn fn_with_defer() { | ||||
| defer {	close() | ||||
| } | ||||
| } | ||||
| 
 | ||||
| struct Foo { | ||||
| 	field1 int | ||||
| 	field2 string | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue