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

cgen: fix innermost value of map fixed array (fix #8214) (#8247)

This commit is contained in:
yuyi 2021-01-22 15:32:56 +08:00 committed by GitHub
parent 522d875489
commit d44c632d11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -2005,6 +2005,7 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
}
}
}
g.is_assign_lhs = false
} else {
is_inside_ternary := g.inside_ternary != 0
cur_line := if is_inside_ternary && is_decl {

View File

@ -8,3 +8,12 @@ fn test_complex_map_fixed_array() {
println(m)
assert '$m' == "{'foo': [[{'bar': 1}, {'baz': 3}]]}"
}
fn test_innermost_value_of_map_fixed_array() {
mut m := map[string][1][2]map[string]int
m['foo'] = [[{'bar': 1}, {'baz': 3}]!]!
println(m['foo'][0][0]['bar'])
println(m['foo'][0][0]['bar'] == 1)
assert m['foo'][0][0]['bar'] == 1
assert '${m['foo'][0][0]['bar']}' == '1'
}