Skip to content

The Precedence Issue of as and Binary Operations #3284

@A4-Tacks

Description

@A4-Tacks

link 01mf02/jaq#261

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

Like:

$ jq -n '"x" as $n | "a"+("y" as $s | $n+","+$s)'
"ax,y"

Or (scope has some impact):

jq: error: $s is not defined at <top-level>, line 1:
"x" as $n | "a"+("y" as $s | $n)+","+$s
jq: 1 compile error

Intuitively, it should be:

$ jq -n '"x" as $n | ("a"+"y") as $s | $n+","+$s'
"x,ay"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions