mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ast: fix error for complex map operating (#14204)
This commit is contained in:
parent
a225b25117
commit
c802688690
@ -2074,6 +2074,10 @@ pub fn (mut lx IndexExpr) recursive_mapset_is_setter(val bool) {
|
||||
if lx.left.is_map {
|
||||
lx.left.recursive_mapset_is_setter(val)
|
||||
}
|
||||
} else if mut lx.left is SelectorExpr {
|
||||
if mut lx.left.expr is IndexExpr {
|
||||
lx.left.expr.recursive_mapset_is_setter(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
24
vlib/v/tests/complex_map_op_test.v
Normal file
24
vlib/v/tests/complex_map_op_test.v
Normal file
@ -0,0 +1,24 @@
|
||||
fn test_complex_map_op() {
|
||||
mut test_map := map[string]Point_map{}
|
||||
|
||||
test_map['test1'].points['point3'] << Point{10, 20}
|
||||
test_map['test2'].points['point4'] << Point{50, 60}
|
||||
|
||||
println(test_map)
|
||||
assert test_map.len == 2
|
||||
assert Point{10, 20} in test_map['test1'].points['point3']
|
||||
assert Point{50, 60} in test_map['test2'].points['point4']
|
||||
assert Point{10, 20} !in test_map['test2'].points['point4']
|
||||
assert Point{1, 2} !in test_map['test1'].points['point3']
|
||||
}
|
||||
|
||||
struct Point {
|
||||
mut:
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
struct Point_map {
|
||||
mut:
|
||||
points map[string][]Point
|
||||
}
|
Loading…
Reference in New Issue
Block a user