Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jan 21, 2025
1 parent 4e68a86 commit 2629bce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/gen/c/assign.v
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
unaliased_right_sym := g.table.final_sym(unwrapped_val_type)
is_fixed_array_var := !g.pref.translated && unaliased_right_sym.kind == .array_fixed
&& val !is ast.ArrayInit
&& (val in [ast.Ident, ast.IndexExpr, ast.CallExpr, ast.SelectorExpr, ast.DumpExpr, ast.InfixExpr]
&& (val in [ast.Ident, ast.IndexExpr, ast.CallExpr, ast.SelectorExpr, ast.DumpExpr, ast.InfixExpr, ast.UnsafeExpr]
|| (val is ast.CastExpr && val.expr !is ast.ArrayInit)
|| (val is ast.PrefixExpr && val.op == .arrow)
|| (val is ast.UnsafeExpr && val.expr in [ast.SelectorExpr, ast.Ident]))
Expand Down
10 changes: 10 additions & 0 deletions vlib/v/tests/builtin_arrays/array_fixed_from_unsafe_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@[unsafe]
fn test() [5]int {
return [5]int{}
}

fn test_main() {
foo := unsafe { test() }
assert foo.len == 5
assert foo == unsafe { test() }
}

0 comments on commit 2629bce

Please sign in to comment.