Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 25, 2024
1 parent f455c82 commit 6091d9f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -5910,8 +5910,10 @@ fn (mut g Gen) return_stmt(node ast.Return) {
if expr is ast.Ident {
g.returned_var_name = expr.name
}
if !use_tmp_var && !g.is_builtin_mod {
use_tmp_var = expr is ast.CallExpr
}
}
// free := g.is_autofree && !g.is_builtin_mod // node.exprs[0] is ast.CallExpr
// Create a temporary variable for the return expression
if use_tmp_var || !g.is_builtin_mod {
// `return foo(a, b, c)`
Expand All @@ -5924,7 +5926,6 @@ fn (mut g Gen) return_stmt(node ast.Return) {
use_tmp_var = true
g.write('${ret_typ} ${tmpvar} = ')
} else {
use_tmp_var = false
if !g.is_builtin_mod {
g.autofree_scope_vars(node.pos.pos - 1, node.pos.line_nr, true)
}
Expand Down

0 comments on commit 6091d9f

Please sign in to comment.