mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix using 'array' name variable in array_init (#16168)
This commit is contained in:
parent
340611c298
commit
7b8044b8c4
@ -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]
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
|
||||
g.is_shared = var_type.has_flag(.shared_f)
|
||||
if is_fixed_array_init && !has_val {
|
||||
if val is ast.ArrayInit {
|
||||
g.array_init(val, ident.name)
|
||||
g.array_init(val, c_name(ident.name))
|
||||
} else {
|
||||
g.write('{0}')
|
||||
}
|
||||
@ -460,7 +460,7 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
|
||||
g.write('*')
|
||||
}
|
||||
if val is ast.ArrayInit {
|
||||
g.array_init(val, ident.name)
|
||||
g.array_init(val, c_name(ident.name))
|
||||
} else if val_type.has_flag(.shared_f) {
|
||||
g.expr_with_cast(val, val_type, var_type)
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user