Skip to content

Commit

Permalink
fix autofree
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Dec 29, 2024
1 parent 1f6af15 commit 21a5dc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 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 @@ -2718,8 +2718,9 @@ fn (mut g Gen) call_cfn_for_casting_expr(fname string, expr ast.Expr, exp_is_ptr
if got_styp == 'none' && !g.cur_fn.return_type.has_flag(.option) {
g.write('(none){EMPTY_STRUCT_INITIALIZATION}')
} else if is_comptime_variant {
g.write(g.type_default(g.type_resolver.get_ct_type_or_default('${g.comptime.comptime_for_variant_var}.typ',
ast.void_type)))
ctyp := g.type_resolver.get_ct_type_or_default('${g.comptime.comptime_for_variant_var}.typ',
ast.void_type)
g.write(g.type_default(ctyp))
} else {
g.expr(expr)
}
Expand Down
10 changes: 6 additions & 4 deletions vlib/v/type_resolver/comptime_resolver.v
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,18 @@ pub fn (mut t TypeResolver) get_expr_type_or_default(node ast.Expr, default_typ
// get_type_from_comptime_var retrives the comptime type related to $for variable
@[inline]
pub fn (t &TypeResolver) get_type_from_comptime_var(var ast.Ident) ast.Type {
return match var.name {
match var.name {
t.info.comptime_for_variant_var {
t.get_ct_type_or_default('${t.info.comptime_for_variant_var}.typ', ast.void_type)
return t.get_ct_type_or_default('${t.info.comptime_for_variant_var}.typ',
ast.void_type)
}
t.info.comptime_for_method_param_var {
t.get_ct_type_or_default('${t.info.comptime_for_method_param_var}.typ', ast.void_type)
return t.get_ct_type_or_default('${t.info.comptime_for_method_param_var}.typ',
ast.void_type)
}
else {
// field_var.typ from $for field
t.info.comptime_for_field_type
return t.info.comptime_for_field_type
}
}
}
Expand Down

0 comments on commit 21a5dc4

Please sign in to comment.