mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: write empty or blocks the same as empty fn bodies, empty structs, etc (#9136)
This commit is contained in:
@@ -850,7 +850,11 @@ pub fn (mut f Fmt) or_expr(node ast.OrExpr) {
|
||||
.absent {}
|
||||
.block {
|
||||
if node.stmts.len == 0 {
|
||||
f.write(' or { }')
|
||||
f.write(' or {')
|
||||
if node.pos.line_nr != node.pos.last_line {
|
||||
f.writeln('')
|
||||
}
|
||||
f.write('}')
|
||||
return
|
||||
} else if node.stmts.len == 1 && stmt_is_single_line(node.stmts[0]) {
|
||||
// the control stmts (return/break/continue...) print a newline inside them,
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
fn main() {
|
||||
empty_or_block() or {}
|
||||
empty_or_block() or {
|
||||
}
|
||||
}
|
||||
|
||||
fn fn_with_or() int {
|
||||
fn_with_optional() or { return 10 }
|
||||
return 20
|
||||
|
||||
Reference in New Issue
Block a user