Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 17, 2025
1 parent f9106a8 commit 8f7557f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/gen/c/assign.v
Original file line number Diff line number Diff line change
Expand Up @@ -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('});')
Expand Down
21 changes: 21 additions & 0 deletions vlib/v/tests/indexexpr_with_anon_fn_test.v
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 8f7557f

Please sign in to comment.