Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 23, 2023
1 parent 0aca08e commit e2df780
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion vlib/v/gen/c/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) {
unwrap_option := expr is ast.Ident && expr.or_expr.kind == .propagate_option
exp_typ := if unwrap_option { typ.clear_flag(.option) } else { typ }
is_ptr := exp_typ.is_ptr()
is_dump_expr := expr is ast.DumpExpr
is_var_mut := expr.is_auto_deref_var()
str_fn_name := g.get_str_fn(exp_typ)
if is_ptr && !is_var_mut {
Expand All @@ -130,7 +131,14 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) {
}
g.write('${str_fn_name}(')
if str_method_expects_ptr && !is_ptr {
g.write('&')
if is_dump_expr {
g.write('ADDR(${g.typ(typ)}, ')
defer {
g.write(')')
}
} else {
g.write('&')
}
} else if is_ptr && typ.has_flag(.option) {
g.write('*(${g.typ(typ)}*)&')
} else if !str_method_expects_ptr && !is_shared && (is_ptr || is_var_mut) {
Expand Down

0 comments on commit e2df780

Please sign in to comment.