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 {}
|
.absent {}
|
||||||
.block {
|
.block {
|
||||||
if node.stmts.len == 0 {
|
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
|
return
|
||||||
} else if node.stmts.len == 1 && stmt_is_single_line(node.stmts[0]) {
|
} else if node.stmts.len == 1 && stmt_is_single_line(node.stmts[0]) {
|
||||||
// the control stmts (return/break/continue...) print a newline inside them,
|
// 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 fn_with_or() int {
|
||||||
fn_with_optional() or { return 10 }
|
fn_with_optional() or { return 10 }
|
||||||
return 20
|
return 20
|
||||||
|
|
Loading…
Reference in New Issue