mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
815c4b7420
commit
2eb11110d6
@ -110,7 +110,14 @@ fn (mut g Gen) array_init(node ast.ArrayInit) {
|
||||
g.write('\t\t')
|
||||
}
|
||||
for i, expr in node.exprs {
|
||||
g.expr_with_cast(expr, node.expr_types[i], node.elem_type)
|
||||
if node.expr_types[i] == ast.string_type && expr !is ast.StringLiteral
|
||||
&& expr !is ast.StringInterLiteral {
|
||||
g.write('string_clone(')
|
||||
g.expr(expr)
|
||||
g.write(')')
|
||||
} else {
|
||||
g.expr_with_cast(expr, node.expr_types[i], node.elem_type)
|
||||
}
|
||||
if i != len - 1 {
|
||||
if i > 0 && i & 7 == 0 { // i > 0 && i % 8 == 0
|
||||
g.writeln(',')
|
||||
|
11
vlib/v/tests/valgrind/array_init_with_string_variable.v
Normal file
11
vlib/v/tests/valgrind/array_init_with_string_variable.v
Normal file
@ -0,0 +1,11 @@
|
||||
module main
|
||||
|
||||
fn main() {
|
||||
a := 'Hello, '
|
||||
b := 'World!'
|
||||
c := a + b
|
||||
|
||||
d := [a, b, c]
|
||||
|
||||
println(d.len)
|
||||
}
|
Loading…
Reference in New Issue
Block a user