From fb51cd0ac32f452a243e67baf9ddc43b747234c4 Mon Sep 17 00:00:00 2001 From: yuyi Date: Mon, 13 Jan 2025 21:19:00 +0800 Subject: [PATCH] fix option_ok() args --- vlib/v/gen/c/cgen.v | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index a1c13806cd762f..bcd1456c31ccfb 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -6719,9 +6719,11 @@ fn (mut g Gen) gen_or_block_stmts(cvar_name string, cast_typ string, stmts []ast g.write('*(${cast_typ}*) ${cvar_name}.data = ') } } else if g.inside_opt_or_res && return_is_option && g.inside_assign { - g.write('_option_ok(&(${cast_typ}[]) { ') + tmp_var := g.new_tmp_var() + g.write('${cast_typ} ${tmp_var} = ') g.expr_with_cast(expr_stmt.expr, expr_stmt.typ, return_type.clear_option_and_result()) - g.writeln(' }, (${g.styp(return_type)}*)&(${cvar_name}.data), sizeof(${cast_typ}));') + g.writeln(';') + g.writeln('_option_ok(&(${cast_typ}[]) { ${tmp_var} }, (${g.styp(return_type)}*)${cvar_name}.data, sizeof(${cast_typ}));') g.indent-- return } else {