cgen: fix array init with it (fix #14679) (#14680)

This commit is contained in:
ChAoS_UnItY 2022-06-06 00:41:54 +08:00 committed by GitHub
parent 3a90d8ef14
commit df80b33dc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View file

@ -1590,3 +1590,14 @@ fn test_inline_array_element_access() {
a2 := [1][0]
assert a2 == 1
}
//
fn f(x int, y int) []int {
return [x, y]
}
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]]
}