Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some binary operator and as operator precedence fail #261

Open
A4-Tacks opened this issue Feb 25, 2025 · 2 comments
Open

Some binary operator and as operator precedence fail #261

A4-Tacks opened this issue Feb 25, 2025 · 2 comments

Comments

@A4-Tacks
Copy link

The precedence of jaq and jq here is not the same, although I am annoyed by jq's design

$ jaq -n '"x" as $n | "a"+"y" as $s | $n+","+$s'
"x,ay"
$ jq  -n '"x" as $n | "a"+"y" as $s | $n+","+$s'
"ax,y"

Add parens:

$ jq  -n '"x" as $n | "a"+("y" as $s | $n+","+$s)'
"ax,y"
$ jaq -n '"x" as $n | "a"+("y" as $s | $n+","+$s)'
"ax,y"
$ jq  -n '"x" as $n | ("a"+"y") as $s | $n+","+$s'
"x,ay"
$ jaq -n '"x" as $n | ("a"+"y") as $s | $n+","+$s'
"x,ay"
@01mf02
Copy link
Owner

01mf02 commented Mar 4, 2025

I would have never expected that! Could you perhaps open an issue on jq's repository? I'm not entirely convinced that jq's behaviour is intended ... especially given that the operator precedence table suggests that + has a higher precedence than |.

@A4-Tacks
Copy link
Author

A4-Tacks commented Mar 5, 2025

Ok jqlang/jq#3284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants