Fix parser to allow binary operators for binding syntax (#3326)
Previously, the precedence of `as` binding was higher than the binary
operators. This results in unexpected behaviors, `1 + 2 as $x | -$x`
was `-1` instead of `-3`. The commit 92daac90f6 (PR #3053) changed
the behavior to emit syntax error on this case. Now, this commit allows
binary operators with `as` binding. This fixes #2446, and fixes #3284.
This commit is contained in:
1 parent
4e3088f188
commit
aaace5432a
3 files changed
+522
-524
No files matched your search
Generated
+513
-523
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -325,7 +325,7 @@ Query:
|
||||
FuncDef Query %prec FUNCDEF {
|
||||
$$ = block_bind_referenced($1, $2, OP_IS_CALL_PSEUDO);
|
||||
} |
|
||||
Term "as" Patterns '|' Query {
|
||||
Expr "as" Patterns '|' Query {
|
||||
$$ = gen_destructure($1, $3, $5);
|
||||
} |
|
||||
"label" BINDING '|' Query {
|
||||
|
||||
@@ -513,6 +513,14 @@ null
|
||||
34324
|
||||
43
|
||||
|
||||
1 + 2 as $x | -$x
|
||||
null
|
||||
-3
|
||||
|
||||
"x" as $x | "a"+"y" as $y | $x+","+$y
|
||||
null
|
||||
"x,ay"
|
||||
|
||||
1 as $x | [$x,$x,$x as $x | $x]
|
||||
null
|
||||
[1,1,1]
|
||||
|
||||
Reference in new issue
Block a user