You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Indexing with an object should emit an error but does not against null.
To Reproduce
% echo 'null' | jq '.[{}]'
null
% echo '{}' | jq '.[{}]'
jq: error (at <stdin>:1): Cannot index object with object
% echo 'null' | jq '.[[]]'
jq: error (at <stdin>:1): Cannot index object with array
% echo '{}' | jq '.[[]]'
jq: error (at <stdin>:1): Cannot index object with array
The first case should be an error as well
Expected behavior
% echo 'null' | jq '.[{}]'
jq: error (at <stdin>:1): Cannot index null with object
Also echo 'null' | jq '.[[]]' should print Cannot index null with array.
Environment (please complete the following information):
OS and Version: macOS
jq version: jq-master-50a7022
Additional Context
The path function does not emit an error quickly for this case so this function can return an invalid object entry as a path (an element in a path should be either a number, a string or an object with start and end).
% echo 'null' | jq 'path(.[{"x":42}])'
[
{
"x": 42
}
]
% echo 'null' | jq '.[{"x":42}] = 1'
jq: error (at <stdin>:1): Start and end indices of an array slice must be numbers
This is a case which shows that null | path(.X) succeeds but null | .X = 1 fails.
The text was updated successfully, but these errors were encountered:
itchyny
changed the title
index using object should always emit an error
index using object (without start and end) should always emit an error
Mar 3, 2020
Describe the bug
Indexing with an object should emit an error but does not against null.
To Reproduce
The first case should be an error as well
Expected behavior
Also
echo 'null' | jq '.[[]]'
should printCannot index null with array
.Environment (please complete the following information):
Additional Context
The
path
function does not emit an error quickly for this case so this function can return an invalid object entry as a path (an element in a path should be either a number, a string or an object with start and end).This is a case which shows that
null | path(.X)
succeeds butnull | .X = 1
fails.The text was updated successfully, but these errors were encountered: