Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Oct 7, 2023
1 parent b3dc7b2 commit 1134bc4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -1803,9 +1803,14 @@ fn (mut g Gen) stmts_with_tmp_var(stmts []ast.Stmt, tmp_var string) bool {
g.expr(stmt.expr)
g.writeln(';')
} else {
styp = g.typ(stmt.typ)
ret_typ := if g.inside_assign {
stmt.typ
} else {
g.fn_decl.return_type.clear_flag(.option)
}
styp = g.base_type(ret_typ)
g.write('_option_ok(&(${styp}[]) { ')
g.expr_with_cast(stmt.expr, stmt.typ, stmt.typ.set_flag(.option))
g.expr_with_cast(stmt.expr, stmt.typ, ret_typ)
g.writeln(' }, (${c.option_name}*)(&${tmp_var}), sizeof(${styp}));')
}
}
Expand Down

0 comments on commit 1134bc4

Please sign in to comment.