mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix alias of map delete (#15644)
This commit is contained in:
parent
1ef95fdec6
commit
a5aad6f791
@ -980,3 +980,16 @@ fn test_map_set_fixed_array_variable() {
|
||||
println(m2)
|
||||
assert '$m2' == "{'A': [1.1, 2.2]}"
|
||||
}
|
||||
|
||||
type Map = map[int]int
|
||||
|
||||
fn test_alias_of_map_delete() {
|
||||
mut m := Map(map[int]int{})
|
||||
m[11] = 111
|
||||
m[22] = 222
|
||||
println(m)
|
||||
m.delete(11)
|
||||
println(m)
|
||||
assert m.len == 1
|
||||
assert m[22] == 222
|
||||
}
|
||||
|
@ -832,8 +832,8 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
||||
}
|
||||
}
|
||||
|
||||
if left_sym.kind == .map && node.name == 'delete' {
|
||||
left_info := left_sym.info as ast.Map
|
||||
if final_left_sym.kind == .map && node.name == 'delete' {
|
||||
left_info := final_left_sym.info as ast.Map
|
||||
elem_type_str := g.typ(left_info.key_type)
|
||||
g.write('map_delete(')
|
||||
if left_type.has_flag(.shared_f) {
|
||||
|
Loading…
Reference in New Issue
Block a user