mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
parent
d5aa37d8b7
commit
3b0cfbfd0f
@ -444,7 +444,7 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
|
||||
g.is_assign_lhs = false
|
||||
g.is_arraymap_set = false
|
||||
if mut left is ast.IndexExpr {
|
||||
sym := g.table.sym(left.left_type)
|
||||
sym := g.table.final_sym(left.left_type)
|
||||
if sym.kind in [.map, .array] {
|
||||
g.expr(val)
|
||||
g.writeln('});')
|
||||
|
21
vlib/v/tests/indexexpr_with_anon_fn_test.v
Normal file
21
vlib/v/tests/indexexpr_with_anon_fn_test.v
Normal file
@ -0,0 +1,21 @@
|
||||
module main
|
||||
|
||||
pub struct Tree {}
|
||||
|
||||
pub type TreeBelt = map[string]fn (input &Tree, belt TreeBelt) []&Tree
|
||||
|
||||
pub fn (tree &Tree) processed() TreeBelt {
|
||||
mut blet := TreeBelt(map[string]fn (&Tree, TreeBelt) []&Tree{})
|
||||
blet['foo'] = fn (input &Tree, belt TreeBelt) []&Tree {
|
||||
return [input]
|
||||
}
|
||||
return blet
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
tree := Tree{}
|
||||
ret := tree.processed()
|
||||
assert ret.len == 1
|
||||
ret2 := ret['foo'](tree, ret)
|
||||
assert ret2[0] == tree
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user