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:
itchyny authored and GitHub committed 2025-05-23 21:25:30 +09:00
1 parent 4e3088f188
commit aaace5432a
3 files changed
+522 -524

No files matched your search

+8
View File
@@ -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]