cgen: fix enum in map (#9912)
parent
a065d014a2
commit
6795b02e24
|
@ -617,6 +617,15 @@ type ColorAlias = Color
|
||||||
fn test_alias_enum() {
|
fn test_alias_enum() {
|
||||||
mut m := map[ColorAlias]string{}
|
mut m := map[ColorAlias]string{}
|
||||||
m[Color.red] = 'hi'
|
m[Color.red] = 'hi'
|
||||||
|
assert m[Color.red] == 'hi'
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_enum_in_map() {
|
||||||
|
mut m := map[Color]string{}
|
||||||
|
m[Color.red] = 'hi'
|
||||||
|
assert Color.red in m
|
||||||
|
assert Color.green !in m
|
||||||
|
assert Color.blue !in m
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_voidptr_keys() {
|
fn test_voidptr_keys() {
|
||||||
|
|
|
@ -3537,8 +3537,8 @@ fn (mut g Gen) infix_in_or_not_in(node ast.InfixExpr, left_sym ast.TypeSymbol, r
|
||||||
} else if right_sym.kind == .map {
|
} else if right_sym.kind == .map {
|
||||||
g.write('_IN_MAP(')
|
g.write('_IN_MAP(')
|
||||||
if !node.left_type.is_ptr() {
|
if !node.left_type.is_ptr() {
|
||||||
left_type_str := g.table.type_to_str(node.left_type)
|
styp := g.typ(node.left_type)
|
||||||
g.write('ADDR($left_type_str, ')
|
g.write('ADDR($styp, ')
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue