mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
df80b33dc0
commit
ce771876a3
@ -484,7 +484,7 @@ fn (mut g Gen) index_of_map(node ast.IndexExpr, sym ast.TypeSymbol) {
|
||||
if !node.is_option {
|
||||
g.or_block(tmp_opt, node.or_expr, elem_type)
|
||||
}
|
||||
g.write('\n$cur_line*($elem_type_str*)${tmp_opt}.data')
|
||||
g.write('\n${cur_line}(*($elem_type_str*)${tmp_opt}.data)')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
24
vlib/v/tests/nested_map_index_test.v
Normal file
24
vlib/v/tests/nested_map_index_test.v
Normal file
@ -0,0 +1,24 @@
|
||||
struct Foo {
|
||||
mut:
|
||||
foo map[int]Bar
|
||||
}
|
||||
|
||||
struct Bar {
|
||||
mut:
|
||||
bar map[int]string
|
||||
}
|
||||
|
||||
fn test_nested_map_index() ? {
|
||||
f := Foo{
|
||||
foo: {
|
||||
11: Bar{
|
||||
bar: {
|
||||
22: 'hello'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ret := f.foo[11]?.bar[22]?
|
||||
println(ret)
|
||||
assert ret == 'hello'
|
||||
}
|
Loading…
Reference in New Issue
Block a user