Package
rsonpath-syntax
Describe the bug
Formatting a ParseError via its Display impl (e.g. println!("{e}"), .to_string(), or any logger) panics when the parse error occurs at end of input for filter-expression errors. The parser emits a zero-length error span in that case, which the display code turns into an inverted byte range, causing an arithmetic underflow in src/error/formatter.rs.
thread 'main' panicked at rsonpath-syntax/src/error/formatter.rs:318:9:
attempt to subtract with overflow
Minimal Reproducible Example
fn main() {
for q in ["$.a[?", "$[?@.b =="] {
match rsonpath_syntax::parse(q) {
Ok(_) => println!("[{q:?}] OK"),
Err(e) => println!("[{q:?}] {e}"), // panics
}
}
}
Expected behavior
The error should render normally, for example:
error: invalid filter expression syntax
$.a[?
^ not a valid filter expression
(byte 5)
Version of the release
v0.4.2 (rsonpath-syntax). Regression introduced in v0.4.1; v0.4.0 renders without panicking.
Package
rsonpath-syntax
Describe the bug
Formatting a
ParseErrorvia itsDisplayimpl (e.g.println!("{e}"),.to_string(), or any logger) panics when the parse error occurs at end of input for filter-expression errors. The parser emits a zero-length error span in that case, which the display code turns into an inverted byte range, causing an arithmetic underflow insrc/error/formatter.rs.Minimal Reproducible Example
Expected behavior
The error should render normally, for example:
Version of the release
v0.4.2 (rsonpath-syntax). Regression introduced in v0.4.1; v0.4.0 renders without panicking.