1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix assignment of fixed array var to another var (#7429)

This commit is contained in:
joe-conigliaro
2020-12-21 16:03:09 +11:00
committed by GitHub
parent c9171ebe9a
commit f0391f7a8f
2 changed files with 42 additions and 4 deletions

View File

@ -79,3 +79,25 @@ fn test_merge() {
assert merge<int>(a, c) == a
assert merge<int>(d, b) == b
}
fn test_fixed_array_assignment() {
mut a := [2]int{}
a[0] = 111
a[1] = 222
b := a
assert b[0] == a[0]
assert b[1] == a[1]
mut c := [2]int{}
c = a
assert c[0] == a[0]
assert c[1] == a[1]
d := [3]int{init: 333}
for val in d {
assert val == 333
}
e := [3]string{init: 'vlang'}
for val in e {
assert val == 'vlang'
}
}