checker: fix error of map selector assign (#12902)
parent
d07975335d
commit
7c85c2ab1f
|
@ -300,6 +300,13 @@ pub fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
|||
c.error('non-name on the left side of `:=`', left.pos)
|
||||
}
|
||||
}
|
||||
ast.SelectorExpr {
|
||||
if mut left.expr is ast.IndexExpr {
|
||||
if left.expr.is_map {
|
||||
left.expr.is_setter = true
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if mut left is ast.IndexExpr {
|
||||
// eprintln('>>> left.is_setter: ${left.is_setter:10} | left.is_map: ${left.is_map:10} | left.is_array: ${left.is_array:10}')
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
struct Test {
|
||||
mut:
|
||||
data int
|
||||
}
|
||||
|
||||
fn test_map_selector_assign() {
|
||||
mut m := map[int]Test{}
|
||||
m[0].data = 1
|
||||
println(m[0].data)
|
||||
assert m[0].data == 1
|
||||
}
|
Loading…
Reference in New Issue