1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: edge case for multi-returns

This commit is contained in:
Emily Hudson 2020-06-15 21:30:16 +01:00 committed by GitHub
parent 41e0561b05
commit 49d7a151b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2355,6 +2355,14 @@ fn (mut g Gen) return_statement(node ast.Return) {
g.write('return ')
styp = g.typ(g.fn_decl.return_type)
}
// Edge case handling for 2 multi returns of the same type
if node.exprs.len == 1 && g.expr_is_multi_return_call(node.exprs[0]) {
g.go_before_stmt(0)
g.write('return ')
g.expr(node.exprs[0])
g.writeln(';')
return
}
// Use this to keep the tmp assignments in order
mut multi_unpack := ''
g.write('($styp){')