1
0
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:
yuyi 2021-09-10 19:30:30 +08:00 committed by GitHub
parent 6ea750da8d
commit 91c6eeeae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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(')')
}
}

View 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]'
}