Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Feb 2, 2025
1 parent 39f2435 commit e041e81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -4012,10 +4012,11 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
mut sum_type_dot := '.'
mut field_typ := ast.void_type
mut is_option_unwrap := false
is_iface_or_sumtype := sym.kind in [.interface, .sum_type]
if f := g.table.find_field_with_embeds(sym, node.field_name) {
field_sym := g.table.sym(f.typ)
field_typ = f.typ
if sym.kind in [.interface, .sum_type] {
if is_iface_or_sumtype {
g.write('(*(')
}
is_option := field_typ.has_flag(.option)
Expand All @@ -4036,7 +4037,7 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
for i, typ in field.smartcasts {
if i == 0 && (is_option_unwrap || nested_unwrap) {
deref := if g.inside_selector {
if sym.kind in [.interface, .sum_type] {
if is_iface_or_sumtype {
'*'.repeat(field.smartcasts.last().nr_muls())
} else {
'*'.repeat(field.smartcasts.last().nr_muls() + 1)
Expand Down Expand Up @@ -4142,7 +4143,7 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
return
}
} else {
if sym.kind in [.interface, .sum_type] {
if is_iface_or_sumtype {
g.write('(*(')
}
}
Expand Down

0 comments on commit e041e81

Please sign in to comment.