fix fixed_array slice ommit high_value (#8025)
parent
57dd511c9d
commit
80008a40e2
|
@ -3894,6 +3894,10 @@ fn (mut g Gen) index_expr(node ast.IndexExpr) {
|
||||||
g.write(', ')
|
g.write(', ')
|
||||||
if node.index.has_high {
|
if node.index.has_high {
|
||||||
g.expr(node.index.high)
|
g.expr(node.index.high)
|
||||||
|
} else if sym.kind == .array_fixed {
|
||||||
|
g.write('_ARR_LEN(')
|
||||||
|
g.expr(node.left)
|
||||||
|
g.write(')')
|
||||||
} else {
|
} else {
|
||||||
g.expr(node.left)
|
g.expr(node.left)
|
||||||
g.write('.len')
|
g.write('.len')
|
||||||
|
|
|
@ -29,3 +29,11 @@ fn test_access_slice_attribute() {
|
||||||
assert access_slice_attribute(mut arr) == 4
|
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