Cannot create empty slices when range start with the array length
bug: It's not possible to create an empty slice when the start range starts with the arrays current length.
expect: That the slicing range 1.. would skip the first element and print nothing if the array only had one element.
related: none
code: input
let foo=[bar]
echo @foo[0..]
echo @foo[0..0]
echo @foo[0..1]
echo @foo[1..]
echo @foo[1..1]
let foo=[bar baz]
echo @foo[0..]
echo @foo[0..0]
echo @foo[0..1]
echo @foo[1..]
echo @foo[1..1]
expect: output
bar
\n
bar
\n
\n
bar baz
\n
bar
baz
\n
actual: output
bar
\n
bar
ion: expansion error: invalid index
ion: expansion error: invalid index
bar baz
\n
bar
baz
\n
kernel: 5.12.4-arch1-2
version: ion 1.0.0-alpha (x86_64-unknown-linux-gnu) rev 1170b845
interaction: Run each command after the other
behavior of rust:
code:
fn main() {
let foo=vec!["bar"];
println!("{:?}", &foo[0..]);
println!("{:?}", &foo[0..0]);
println!("{:?}", &foo[0..1]);
println!("{:?}", &foo[1..]);
println!("{:?}", &foo[1..1]);
let foo=vec!["bar", "baz"];
println!("{:?}", &foo[0..]);
println!("{:?}", &foo[0..0]);
println!("{:?}", &foo[0..1]);
println!("{:?}", &foo[1..]);
println!("{:?}", &foo[1..1]);
}
output:
["bar"]
[]
["bar"]
[]
[]
["bar", "baz"]
[]
["bar"]
["baz"]
[]