mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix fixed_array slice ommit high_value (#8025)
This commit is contained in:
parent
57dd511c9d
commit
80008a40e2
@ -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')
|
||||
|
@ -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]]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user