Skip to content

Commit ae66145

Browse files
authored
cgen: fix array init with fixed array from return call (fix #25954) (#25971)
1 parent 2401d63 commit ae66145

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

vlib/v/gen/c/array.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn (mut g Gen) array_init(node ast.ArrayInit, var_name string) {
6161
if node.elem_type.has_flag(.option) {
6262
g.expr_with_opt(expr, expr_type, node.elem_type)
6363
} else if elem_type.unaliased_sym.kind == .array_fixed
64-
&& expr in [ast.Ident, ast.SelectorExpr] {
64+
&& expr in [ast.Ident, ast.SelectorExpr, ast.CallExpr] {
6565
info := elem_type.unaliased_sym.info as ast.ArrayFixed
6666
g.fixed_array_var_init(g.expr_string(expr), expr.is_auto_deref_var(),
6767
info.elem_type, info.size)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module main
2+
3+
fn ret() [2]int {
4+
return [3, 4]!
5+
}
6+
7+
fn test_main() {
8+
coords := [ret()]
9+
assert coords[0] == [3, 4]!
10+
}

0 commit comments

Comments
 (0)