parent
01735c67c6
commit
81dbd72412
|
@ -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.write(') = ')
|
||||
} else {
|
||||
g.is_assign_lhs = true
|
||||
g.assign_op = assign_stmt.op
|
||||
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.expr(val)
|
||||
|
|
|
@ -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'
|
||||
}
|
Loading…
Reference in New Issue