Crash when running simple example
cjappl opened this issue · comments
Chris Apple commented
System: OSX
Version: jaq 1.2.0 (also tip of main b2a7f19)
Installed via: Brew (also tested on repo directly)
Steps to repro:
> echo '{"hi": 1}' | jq
{
"hi": 1
}
> echo '{"hi": 1}' | jaq
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', jaq-interpret/src/filter.rs:227:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The full backtrace does not provide any more interesting information, it looks like:
> echo '{"hi": 1}' | jaq
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', jaq-interpret/src/filter.rs:
227:16
stack backtrace:
0: 0x10320f0fc - __mh_execute_header
1: 0x10321fb74 - __mh_execute_header
2: 0x1031fe944 - __mh_execute_header
3: 0x10320ef04 - __mh_execute_header
haguenau commented
As a comment, but not a full explanation, the issue appears to be related to the processing of (absent) arguments:
$ echo 0 | jaq
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', jaq-interpret/src/filter.rs:227:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo 0 | jaq .
0
Interestingly, it looks like input processing happens before the command line is considered; we get more correctness in the error message when writing invalid JSON:
$ echo { | jaq
Error: failed to parse: value or end of sequence expected
(Interaction is identical with jaq .
.)
Kai Klingenberg commented
Michael Färber commented
This is now corrected in #147.