cgen: fix `b := &[5, 6, 7]` (#11457)
parent
6ea750da8d
commit
91c6eeeae5
|
@ -131,7 +131,7 @@ fn (mut g Gen) array_init(node ast.ArrayInit) {
|
|||
if g.is_shared {
|
||||
g.write('}, sizeof($shared_styp))')
|
||||
} else if is_amp {
|
||||
g.write('), sizeof($array_styp))')
|
||||
g.write(')')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
fn test_reference_array_init() {
|
||||
mut b := &[5, 6, 7]
|
||||
{
|
||||
a := [1, 2, 3]
|
||||
b = &a
|
||||
}
|
||||
println(b)
|
||||
assert '$b' == '&[1, 2, 3]'
|
||||
}
|
Loading…
Reference in New Issue