Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 17, 2023
1 parent 4808151 commit c4a977d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/gen/c/cgen.v
Original file line number Diff line number Diff line change
Expand Up @@ -5247,7 +5247,7 @@ fn (mut g Gen) return_stmt(node ast.Return) {
g.writeln('{0};')
if node.exprs[0] is ast.Ident {
g.write('memcpy(${tmpvar}.ret_arr, ${g.expr_string(node.exprs[0])}, sizeof(${g.typ(node.types[0])})) /*ret*/')
} else if node.exprs[0] is ast.ArrayInit {
} else if node.exprs[0] in [ast.ArrayInit, ast.StructInit] {
tmpvar2 := g.new_tmp_var()
g.write('${g.typ(node.types[0])} ${tmpvar2} = ')
g.expr_with_cast(node.exprs[0], node.types[0], g.fn_decl.return_type)
Expand Down
8 changes: 8 additions & 0 deletions vlib/v/tests/generics_fixed_array_assign_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn init_type[T]() {
_ := T{}
}

fn test_main() {
init_type[[3]int]()
assert true
}

0 comments on commit c4a977d

Please sign in to comment.