fmt: write empty or blocks the same as empty fn bodies, empty structs, etc (#9136)
parent
7a9d9f1e78
commit
fdcfe397d4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue