mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix enum print (#11218)
This commit is contained in:
parent
2bf1015ae1
commit
881510e7ce
@ -92,11 +92,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) {
|
||||
} else if sym.kind == .none_ {
|
||||
g.write('_SLIT("<none>")')
|
||||
} else if sym.kind == .enum_ {
|
||||
is_var := match expr {
|
||||
ast.SelectorExpr, ast.Ident, ast.CTempVar { true }
|
||||
else { false }
|
||||
}
|
||||
if is_var {
|
||||
if expr !is ast.EnumVal {
|
||||
str_fn_name := g.gen_str_for_type(typ)
|
||||
g.write('${str_fn_name}(')
|
||||
g.enum_expr(expr)
|
||||
|
@ -3,4 +3,6 @@ yellow
|
||||
green
|
||||
green
|
||||
interp: green
|
||||
interp: green
|
||||
interp: green
|
||||
orange
|
||||
orange
|
@ -7,7 +7,7 @@ enum Color {
|
||||
yellow = 3
|
||||
}
|
||||
|
||||
struct Aaa{
|
||||
struct Aaa {
|
||||
color Color
|
||||
}
|
||||
|
||||
@ -21,4 +21,6 @@ fn main() {
|
||||
println(a.color)
|
||||
println('interp: ${col}')
|
||||
println('interp: ${a.color}')
|
||||
println((Color.orange))
|
||||
println([Color.orange, Color.green][0])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user