fmt: minor cleanup of return_stmt (#8341)

pull/8328/head
Lukas Neubert 2021-01-25 23:22:14 +01:00 committed by GitHub
parent 4d0dab826b
commit c6f98afaba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -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) {
f.comments(node.comments, {})
f.write('return')
if node.exprs.len > 1 {
// multiple returns
if node.exprs.len > 0 {
f.write(' ')
// Loop over all return values. In normal returns this will only run once.
for i, expr in node.exprs {
f.expr(expr)
if i < node.exprs.len - 1 {
f.write(', ')
}
}
} else if node.exprs.len == 1 {
// normal return
f.write(' ')
f.expr(node.exprs[0])
}
f.writeln('')
}