mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parent
ef049839ab
commit
3b9291a958
@ -357,10 +357,19 @@ pub fn (x Expr) str() string {
|
||||
if x.has_default {
|
||||
fields << 'init: ${x.default_expr.str()}'
|
||||
}
|
||||
typ_str := global_table.type_to_str(x.elem_type)
|
||||
if fields.len > 0 {
|
||||
return '[]T{${fields.join(', ')}}'
|
||||
if x.is_fixed {
|
||||
return '${x.exprs.str()}${typ_str}{${fields.join(', ')}}'
|
||||
} else {
|
||||
return '[]${typ_str}{${fields.join(', ')}}'
|
||||
}
|
||||
} else {
|
||||
return x.exprs.str()
|
||||
if x.is_fixed {
|
||||
return '${x.exprs.str()}${typ_str}{}'
|
||||
} else {
|
||||
return x.exprs.str()
|
||||
}
|
||||
}
|
||||
}
|
||||
AsCast {
|
||||
|
@ -191,12 +191,14 @@ fn (mut g Gen) fixed_array_init(node ast.ArrayInit, array_type Type, var_name st
|
||||
info := array_type.unaliased_sym.info as ast.ArrayFixed
|
||||
arr_info := elem_sym.array_fixed_info()
|
||||
g.expr(ast.ArrayInit{
|
||||
exprs: [ast.IntegerLiteral{}]
|
||||
typ: node.elem_type
|
||||
elem_type: arr_info.elem_type
|
||||
})
|
||||
for _ in 1 .. info.size {
|
||||
g.write(', ')
|
||||
g.expr(ast.ArrayInit{
|
||||
exprs: [ast.IntegerLiteral{}]
|
||||
typ: node.elem_type
|
||||
elem_type: arr_info.elem_type
|
||||
})
|
||||
|
@ -60,6 +60,14 @@ fn (mut g Gen) dump_expr(node ast.DumpExpr) {
|
||||
g.expr(node.expr)
|
||||
g.write('.data)')
|
||||
g.inside_opt_or_res = old_inside_opt_or_res
|
||||
} else if node.expr is ast.ArrayInit {
|
||||
if node.expr.is_fixed {
|
||||
s := g.typ(node.expr.typ)
|
||||
if !node.expr.has_index {
|
||||
g.write('(${s})')
|
||||
}
|
||||
}
|
||||
g.expr(node.expr)
|
||||
} else {
|
||||
old_inside_opt_or_res := g.inside_opt_or_res
|
||||
g.inside_opt_or_res = true
|
||||
|
1
vlib/v/slow_tests/inout/dump_multi_fixed_array_init.out
Normal file
1
vlib/v/slow_tests/inout/dump_multi_fixed_array_init.out
Normal file
@ -0,0 +1 @@
|
||||
[vlib/v/slow_tests/inout/dump_multi_fixed_array_init.vv:2] [2][3]int{}: [[0, 0, 0], [0, 0, 0]]
|
3
vlib/v/slow_tests/inout/dump_multi_fixed_array_init.vv
Normal file
3
vlib/v/slow_tests/inout/dump_multi_fixed_array_init.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
dump([2][3]int{})
|
||||
}
|
@ -0,0 +1 @@
|
||||
[[0, 0, 0], [0, 0, 0]]
|
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println([2][3]int{})
|
||||
}
|
Loading…
Reference in New Issue
Block a user