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

Variable with name "end" #1619

Closed
LukasWallisch opened this issue Mar 9, 2018 · 5 comments
Closed

Variable with name "end" #1619

LukasWallisch opened this issue Mar 9, 2018 · 5 comments
Labels

Comments

@LukasWallisch
Copy link

LukasWallisch commented Mar 9, 2018

Hey guy's i'm not sure if this was already reported and i overlooked it.
If a predefined variable is given the name "end", jq throws an error: "syntax error, unexpected end..."
for example:
$ jq -n --arg last "1" '{end: $last}'
works as expected giving:
{ "end": "1" }

but
$ jq -n --arg end "1" '{end: $end}'
gives:
jq: error: syntax error, unexpected end, expecting IDENT or __loc__ (Unix shell quoting issues?) at <top-level>, line 1: {end: $end} jq: 1 compile error

I don't know how complex it would be to fix this, but at least it should be mentioned in the manual I think.

@nicowilliams
Copy link
Contributor

I'm trying to find a way to permit $<keyword>, but it causes tons of reduce-reduce conflicts from Bison...

@pkoppstein
Copy link
Contributor

@LukasWallisch - The manual probably omits the restriction because it was not intended to be definitive. In the meantime, the jq FAQ mentions the issue in the Caveats section.

@nicowilliams
Copy link
Contributor

I think we'll have to change the lexer to produce a separate token type for $name and the grammar accordingly.

@Alanscut
Copy link
Contributor

hi @LukasWallisch
Now jq can handle the scenario you described ,you can try it again.
jq version : master branch

root@os-001: jq -n --arg end "1" '{end: $end}'
{
  "end": "1"
}


@itchyny
Copy link
Contributor

itchyny commented Jun 3, 2023

Same issue of #1868 and fixed by c72ed13, so closing the issue.

@itchyny itchyny closed this as completed Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants