array: fix memory bug with mutable array args
parent
45e9a8fd66
commit
cec2173381
|
@ -461,7 +461,11 @@ fn (p mut Parser) gen_array_push(ph int, typ, expr_type, tmp, tmp_typ string) {
|
||||||
// Don't dereference if it's already a mutable array argument (`fn foo(mut []int)`)
|
// Don't dereference if it's already a mutable array argument (`fn foo(mut []int)`)
|
||||||
push_call := if typ.contains('*'){'_PUSH('} else { '_PUSH(&'}
|
push_call := if typ.contains('*'){'_PUSH('} else { '_PUSH(&'}
|
||||||
p.cgen.set_placeholder(ph, push_call)
|
p.cgen.set_placeholder(ph, push_call)
|
||||||
p.gen('), $tmp, $tmp_typ)')
|
if tmp_typ.ends_with('*') {
|
||||||
|
p.gen('), $tmp, ${tmp_typ.left(tmp_typ.len - 1)})')
|
||||||
|
} else {
|
||||||
|
p.gen('), $tmp, $tmp_typ)')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue