From d44c632d11d3680910d47ec25ffef3eb2758b5e3 Mon Sep 17 00:00:00 2001 From: yuyi Date: Fri, 22 Jan 2021 15:32:56 +0800 Subject: [PATCH] cgen: fix innermost value of map fixed array (fix #8214) (#8247) --- vlib/v/gen/cgen.v | 1 + vlib/v/tests/map_complex_fixed_array_test.v | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 5982b6d374..5519095fc2 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -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 { diff --git a/vlib/v/tests/map_complex_fixed_array_test.v b/vlib/v/tests/map_complex_fixed_array_test.v index c1d2b97af3..8afceb4954 100644 --- a/vlib/v/tests/map_complex_fixed_array_test.v +++ b/vlib/v/tests/map_complex_fixed_array_test.v @@ -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' +}