jq produces unexpected results when any() is called in this context any(array[]==val)
I'm not sure how jq calculates these results:
$ jq -n '[2,2] | any( [1,2][]|. == .) '
false
$ jq -n '[2,2] | any( [2,1][]|. == .) '
false
# or
$ jq -n '[2,2] | any( [1,2][] == .) '
true
$ jq -n '[2,2] | any( [2,1][] == .) '
false
I'd expect true in all cases?
when using == in explicit expression, the results are as expected.
$ jq -n '([2,2][]) == ([1,2][])'
false
false
true
true
$ jq -n '([2,2][]) == ([2,1][])'
true
true
false
false
How can it be explained?
It seems that is a bug in jq 1.6. I compiled master version which gives correct result :
$ jq --version
jq-1.6-159-gcff5336
$ jq -n '[2,2] | any( [1,2][]|. == .) '
true
$ jq -n '[2,2] | any( [2,1][]|. == .) '
true
$ jq -n '[2,2] | any( [1,2][] == .) '
true
$ jq -n '[2,2] | any( [2,1][] == .) '
true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With