diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index edcee66730..25319f2dbb 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -3902,6 +3902,7 @@ fn (mut g Gen) return_stmt(node ast.Return) { tmpvar := g.new_tmp_var() ret_typ := g.typ(g.unwrap_generic(g.fn_decl.return_type)) mut use_tmp_var := g.defer_stmts.len > 0 || g.defer_profile_code.len > 0 + || g.cur_lock.lockeds.len > 0 // handle promoting none/error/function returning 'Option' if fn_return_is_optional { optional_none := node.exprs[0] is ast.None