According to RFC 9535, the default value for start depends on the sing of step and is len - 1 when step < 0. The JSONPath parser always uses 0 as the default value for start.
Minimal Reproducible Example
let query1 = rsonpath_syntax::parse("$[::-1]").unwrap();
let query2 = rsonpath_syntax::parse("$[0::-1]").unwrap();
assert_ne!(query1, query2);
Expected behavior
$[::-1] and $[0::-1] are different queries, so their ASTs generated by the parser can't be equal.
The start field of the Slice struct should probably be of type Option<Index> and set to None if the value is omitted, just like the end field.
Package
Library
Describe the bug
According to RFC 9535, the default value for
start
depends on the sing ofstep
and islen - 1
whenstep < 0
. The JSONPath parser always uses0
as the default value forstart
.Minimal Reproducible Example
Expected behavior
$[::-1]
and$[0::-1]
are different queries, so their ASTs generated by the parser can't be equal. Thestart
field of theSlice
struct should probably be of typeOption<Index>
and set toNone
if the value is omitted, just like theend
field.Workarounds (optional)
No response
Proposed solution (optional)
No response
Version of the release
v0.9.1
Rust version
1.80.1
Target triple
aarch64-apple-darwin
Features enabled
default
Codegen options
No response
Additional context (optional)
No response