-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
The keyword label
can't be used as a binding name :(
#2675
Comments
It is also possible to use Since we want to allow "$"[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext + 1); return VARIABLE;} Then we should just need to replace all |
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, variable/symbols were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, variable/symbols were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, variable/symbols were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
emanuele6
added a commit
to emanuele6/jq-1
that referenced
this issue
Jul 9, 2023
Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes jqlang#2675
nicowilliams
pushed a commit
that referenced
this issue
Jul 9, 2023
Previously, bindings were parsed as the combination of two tokens: '$' IDENT This meant that using a keyword as variable name (e.g. $then, $label) did not work. Attempts were made to allow $keyword to work by adding some '$' Keyword rules in the parser, but this did not allow $keyword in all places: jq --arg label foo -n '$label' # ok jq -n '"foo" as $label | .' # error Treating $foo as a single token is much simpler, in my opinion. This patch also changes how LOC is lexed: "$__loc__" instead of as "__loc__" that gets combined with '$' in the parser. This patch also disallows having spaces after '$' when recalling a variable `$ foo' since that was probably just an unintentional side effect of the implementation, and it was not documented. Fixes #2675
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We should make sure all keywords can be used as
$keyword
bindings.The text was updated successfully, but these errors were encountered: