mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix map_in mut (#5638)
This commit is contained in:
parent
df2749dd50
commit
dff385cb37
@ -301,3 +301,15 @@ fn test_map_keys_to_array() {
|
|||||||
println(sarr)
|
println(sarr)
|
||||||
assert sarr == "['a', 'c']"
|
assert sarr == "['a', 'c']"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn map_in_mut(mut m map[string]int) {
|
||||||
|
if 'one' in m {
|
||||||
|
m['one'] = 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_map_in_mut() {
|
||||||
|
mut m := {'one': 1}
|
||||||
|
map_in_mut(mut m)
|
||||||
|
assert m['one'] == 2
|
||||||
|
}
|
||||||
|
@ -1912,6 +1912,9 @@ fn (mut g Gen) infix_expr(node ast.InfixExpr) {
|
|||||||
g.write('_IN_MAP(')
|
g.write('_IN_MAP(')
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
|
if node.right_type.is_ptr() {
|
||||||
|
g.write('*')
|
||||||
|
}
|
||||||
g.expr(node.right)
|
g.expr(node.right)
|
||||||
g.write(')')
|
g.write(')')
|
||||||
} else if right_sym.kind == .string {
|
} else if right_sym.kind == .string {
|
||||||
|
Loading…
Reference in New Issue
Block a user