diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index b5d843bce342a6..af949222df715b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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 diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 77e9fc2ae277d1..65b9ec705f96f4 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -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 }