cgen: fix using 'array' name variable in array_init (#16168)

This commit is contained in:
yuyi 2022-10-24 03:23:15 +08:00 committed by GitHub
parent 340611c298
commit 7b8044b8c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -1601,3 +1601,9 @@ fn test_2d_array_init_with_it() {
a := [][]int{len: 6, init: f(it, 2 * it)}
assert a == [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10]]
}
fn test_using_array_name_variable() {
array := []int{len: 4, init: it}
println(array)
assert array == [0, 1, 2, 3]
}