MiSawa / xq

Pure rust implementation of jq
MIT License
333 stars 18 forks source link

error(null) is not handled as backtracking #42

Closed itchyny closed 2 years ago

itchyny commented 2 years ago

While undocumented, jq handles null errors as backtracking.

❯ jq -nc '[error], [0, error, 1], error, 1'
[]
[0,1]
1

❯ xq -nc '[error], [0, error, 1], error, 1'
Error: UserDefinedError("null")

Edit: null | error and error(null) behave as same.

itchyny commented 2 years ago

Note the jq behavior of non-string arguments.

❯ jq -n 'try error({ x: 0 }) catch .'
{
  "x": 0
}

❯ jq -n 'try ([{ x: 0 }] | error) catch .'
[
  {
    "x": 0
  }
]

❯ jq -n 'try error(false) catch .'
false