cgen: fix error of the map literals method call (#10791)
parent
9c710b2a34
commit
fe1cf2ea26
|
@ -778,7 +778,13 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
|||
&& node.name in ['first', 'last', 'repeat'] {
|
||||
g.write('*')
|
||||
}
|
||||
if node.left is ast.MapInit {
|
||||
g.write('(map[]){')
|
||||
g.expr(node.left)
|
||||
g.write('}[0]')
|
||||
} else {
|
||||
g.expr(node.left)
|
||||
}
|
||||
if node.from_embed_type != 0 {
|
||||
embed_name := typ_sym.embed_name()
|
||||
if node.left_type.is_ptr() {
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
fn test_map_literals_method_call() {
|
||||
a := 1 in map{
|
||||
1: 1
|
||||
}.keys().map(map{
|
||||
1: 1
|
||||
}[it])
|
||||
|
||||
println(a)
|
||||
assert a
|
||||
}
|
Loading…
Reference in New Issue