Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 4, 2023
1 parent 8670dcc commit 35934ed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,7 @@ fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
} else if c.inside_comptime_for_field && typ == c.enum_data_type && node.field_name == 'value' {
// for comp-time enum.values
node.expr_type = c.comptime_fields_type[c.comptime_for_field_var]
node.typ = typ
return node.expr_type
}
node.expr_type = typ
Expand Down
7 changes: 6 additions & 1 deletion vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -3634,7 +3634,12 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
if node.expr_type == 0 {
g.checker_bug('unexpected SelectorExpr.expr_type = 0', node.pos)
}

if g.enum_data_type == node.typ {
g.expr(node.expr)
g.write('.')
g.write(node.field_name)
return
}
sym := g.table.sym(g.unwrap_generic(node.expr_type))
field_name := if sym.language == .v { c_name(node.field_name) } else { node.field_name }

Expand Down

0 comments on commit 35934ed

Please sign in to comment.