1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix map value op-assign modification (#7101)

This commit is contained in:
Uwe Krüger
2020-12-03 00:40:11 +01:00
committed by GitHub
parent 1037d3a383
commit c1b25dd61d
3 changed files with 53 additions and 3 deletions

View File

@ -353,3 +353,11 @@ fn test_map_str_after_delete() {
assert osm == "{'first': 1, 'second': 2, 'third': 3}"
assert nsm == "{'first': 1, 'third': 3}"
}
fn test_modify_map_value() {
mut m1 := {'foo': 3, 'bar': -7}
m1['foo'] += 5
m1['bar'] *= -2
assert m1['foo'] == 8
assert m1['bar'] == 14
}