cgen: fix error for printing multi fixed array (#14141)
parent
8a5ba0dfc8
commit
d67251c1e0
|
@ -78,7 +78,7 @@ fn (mut g Gen) array_init(node ast.ArrayInit) {
|
|||
g.inside_lambda = false
|
||||
return
|
||||
}
|
||||
need_tmp_var := g.inside_call && !g.inside_struct_init
|
||||
need_tmp_var := g.inside_call && !g.inside_struct_init && node.exprs.len == 0
|
||||
mut stmt_str := ''
|
||||
mut tmp_var := ''
|
||||
if need_tmp_var {
|
||||
|
|
|
@ -2044,6 +2044,12 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as
|
|||
g.expr(arg.expr)
|
||||
g.write('->val')
|
||||
return
|
||||
} else if arg.expr is ast.ArrayInit {
|
||||
if arg.expr.is_fixed {
|
||||
if !arg.expr.has_it {
|
||||
g.write('(${g.typ(arg.expr.typ)})')
|
||||
}
|
||||
}
|
||||
}
|
||||
g.expr_with_cast(arg.expr, arg_typ, expected_type)
|
||||
if needs_closing {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[[1, 2], [3, 3]]
|
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
a := [[1, 2]!, [3, 3]!]!
|
||||
println([[a[0][0], a[0][1]]!, [a[1][0], a[1][1]]!]!)
|
||||
}
|
Loading…
Reference in New Issue