MiSawa / xq

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

Fix update assignment of modulo operator #63

Closed itchyny closed 2 years ago

itchyny commented 2 years ago

This PR fixes %= operator. Also adds test for all arithmetic assignment operators.

❯ jq -c '.[] %= 2' <<< '[1,2,3]'
[1,0,1]

❯ xq -c '.[] %= 2' <<< '[1,2,3]'
Error: compile query

Caused by:
    ParseError(UnrecognizedToken(Loc { line: 0, col: 5, byte_idx: 5 }, "Eq", ["\"(\"", "\"+\"", "\"-\"", "\".\"", "\"..\"", "\"[\"", "\"break\"", "\"def\"", "\"false\"", "\"foreach\"", "\"if\"", "\"label\"", "\"null\"", "\"reduce\"", "\"true\"", "\"try\"", "\"{\"", "FieldStr", "Format", "IdentifierNonKeywordStr", "ModuleIdentifierStr", "ModuleVariableStr", "Number", "StringStart", "TryNoCatch", "VariableStr"]))

❯ xq --version
xq 0.2.2-867924f3feb34b21e41363c38603dd7b739c8666
MiSawa commented 2 years ago

Awesome, thank you!