diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index 0d964e0168..fe8858a96e 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -3894,6 +3894,10 @@ fn (mut g Gen) index_expr(node ast.IndexExpr) { g.write(', ') if node.index.has_high { g.expr(node.index.high) + } else if sym.kind == .array_fixed { + g.write('_ARR_LEN(') + g.expr(node.left) + g.write(')') } else { g.expr(node.left) g.write('.len') diff --git a/vlib/v/tests/array_slice_test.v b/vlib/v/tests/array_slice_test.v index 4d06e3ce71..2cf12c25c1 100644 --- a/vlib/v/tests/array_slice_test.v +++ b/vlib/v/tests/array_slice_test.v @@ -29,3 +29,11 @@ fn test_access_slice_attribute() { assert access_slice_attribute(mut arr) == 4 } +fn test_fixed_array_slice() { + fixed_array1 := [1, 2, 3]! + arr1 := fixed_array1[0..] + assert arr1 == [1, 2, 3] + fixed_array2 := [[1, 2], [2, 3], [3, 4],[4, 5]]! + arr2 := fixed_array2[0..] + assert arr2 == [[1, 2], [2, 3], [3, 4],[4, 5]] +}