mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: minor cleanup of return_stmt (#8341)
This commit is contained in:
parent
4d0dab826b
commit
c6f98afaba
@ -2335,19 +2335,15 @@ pub fn (mut f Fmt) go_stmt(node ast.GoStmt, is_expr bool) {
|
|||||||
pub fn (mut f Fmt) return_stmt(node ast.Return) {
|
pub fn (mut f Fmt) return_stmt(node ast.Return) {
|
||||||
f.comments(node.comments, {})
|
f.comments(node.comments, {})
|
||||||
f.write('return')
|
f.write('return')
|
||||||
if node.exprs.len > 1 {
|
if node.exprs.len > 0 {
|
||||||
// multiple returns
|
|
||||||
f.write(' ')
|
f.write(' ')
|
||||||
|
// Loop over all return values. In normal returns this will only run once.
|
||||||
for i, expr in node.exprs {
|
for i, expr in node.exprs {
|
||||||
f.expr(expr)
|
f.expr(expr)
|
||||||
if i < node.exprs.len - 1 {
|
if i < node.exprs.len - 1 {
|
||||||
f.write(', ')
|
f.write(', ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if node.exprs.len == 1 {
|
|
||||||
// normal return
|
|
||||||
f.write(' ')
|
|
||||||
f.expr(node.exprs[0])
|
|
||||||
}
|
}
|
||||||
f.writeln('')
|
f.writeln('')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user