mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
@@ -1952,7 +1952,18 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
|
|||||||
g.definitions.go_back(g.definitions.len - def_pos)
|
g.definitions.go_back(g.definitions.len - def_pos)
|
||||||
g.write(') = ')
|
g.write(') = ')
|
||||||
} else {
|
} else {
|
||||||
|
g.is_assign_lhs = true
|
||||||
|
g.assign_op = assign_stmt.op
|
||||||
g.expr(left)
|
g.expr(left)
|
||||||
|
g.is_assign_lhs = false
|
||||||
|
if left is ast.IndexExpr {
|
||||||
|
sym := g.table.get_type_symbol(left.left_type)
|
||||||
|
if sym.kind in [.map, .array] {
|
||||||
|
g.expr(val)
|
||||||
|
g.writeln('});')
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
g.write(' = ')
|
g.write(' = ')
|
||||||
}
|
}
|
||||||
g.expr(val)
|
g.expr(val)
|
||||||
|
|||||||
13
vlib/v/tests/anon_fn_in_containers_test.v
Normal file
13
vlib/v/tests/anon_fn_in_containers_test.v
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
fn test_anon_fn_in_map() {
|
||||||
|
mut woop := map{
|
||||||
|
'what': fn() string {
|
||||||
|
return 'whoopity whoop'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert woop['what']() == 'whoopity whoop'
|
||||||
|
|
||||||
|
woop['shat'] = fn() string {
|
||||||
|
return 'shoopity shoop'
|
||||||
|
}
|
||||||
|
assert woop['shat']() == 'shoopity shoop'
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user