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

cgen: fix default zero in map fields (fix #7328) (#7394)

This commit is contained in:
yuyi
2020-12-19 13:55:13 +08:00
committed by GitHub
parent c0f4c525d2
commit 598d18cbd9
2 changed files with 31 additions and 1 deletions

View File

@ -440,3 +440,16 @@ fn test_map_clone() {
assert nums2['foo'] == 2
assert nums2['bar'] == 8
}
struct MValue {
name string
misc map[string]string
}
fn test_map_default_zero() {
m := map[string]MValue{}
v := m['unknown']
x := v.misc['x']
println(x)
assert x == ''
}