checker: fix map init with enum keys (#12637)
parent
8494e387ec
commit
988779846f
|
@ -7744,6 +7744,7 @@ pub fn (mut c Checker) map_init(mut node ast.MapInit) ast.Type {
|
|||
continue
|
||||
}
|
||||
val := node.vals[i]
|
||||
c.expected_type = key0_type
|
||||
key_type := c.expr(key)
|
||||
c.expected_type = val0_type
|
||||
val_type := c.expr(val)
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
enum En {
|
||||
ea
|
||||
eb
|
||||
}
|
||||
|
||||
struct St {
|
||||
mut:
|
||||
m map[En]string
|
||||
}
|
||||
|
||||
fn test_map_init_with_enum_keys() {
|
||||
mut st := St{}
|
||||
|
||||
st.m = {
|
||||
.ea: 'a'
|
||||
}
|
||||
|
||||
println(st.m)
|
||||
assert '$st.m' == "{ea: 'a'}"
|
||||
}
|
Loading…
Reference in New Issue