rsonquery / rsonpath

Blazing fast JSONPath query engine written in Rust.
https://rsonquery.github.io/rsonpath/
MIT License
50 stars 8 forks source link

Incorrect default value for `start` when `step` is negative in the slice selector #546

Open lukasz05 opened 5 hours ago

lukasz05 commented 5 hours ago

Package

Library

Describe the bug

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.

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

github-actions[bot] commented 5 hours ago

Tagging @V0ldek for notifications