mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix b := &[5, 6, 7]
(#11457)
This commit is contained in:
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(')')
|
||||
}
|
||||
}
|
||||
|
||||
|
9
vlib/v/tests/ref_array_init_test.v
Normal file
9
vlib/v/tests/ref_array_init_test.v
Normal file
@ -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
Block a user