Skip to content

Commit 586bc1f

Browse files
committed
interp: Cleaup query ast code after gojq update (#1223)
"<expr> as $v | <body>" is now pipe binop with a pattern, before suffix list body was used
1 parent 8076381 commit 586bc1f

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

pkg/interp/query.jq

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,7 @@ def _query_try(b):
130130
# last query in pipeline
131131
def _query_pipe_last:
132132
if .term.suffix_list then
133-
( .term.suffix_list[-1]
134-
| if .bind.body then
135-
( .bind.body
136-
| _query_pipe_last
137-
)
138-
end
139-
)
133+
.term.suffix_list[-1]
140134
elif .op == "|" then
141135
( .right
142136
| _query_pipe_last
@@ -146,11 +140,7 @@ def _query_pipe_last:
146140
def _query_transform_pipe_last(f):
147141
def _f:
148142
if .term.suffix_list then
149-
.term.suffix_list[-1] |=
150-
if .bind.body then
151-
.bind.body |= _f
152-
else f
153-
end
143+
.term.suffix_list[-1] |= f
154144
elif .op == "|" then
155145
.right |= _f
156146
else f
@@ -160,13 +150,7 @@ def _query_transform_pipe_last(f):
160150
# last term, the right most
161151
def _query_last:
162152
if .term.suffix_list then
163-
( .term.suffix_list[-1]
164-
| if .bind.body then
165-
( .bind.body
166-
| _query_last
167-
)
168-
end
169-
)
153+
.term.suffix_list[-1]
170154
elif .op then
171155
( .right
172156
| _query_last
@@ -177,12 +161,7 @@ def _query_last:
177161
def _query_transform_last(f):
178162
def _f:
179163
if .term.suffix_list then
180-
( .
181-
| if .term.suffix_list[-1].bind.body then
182-
.term.suffix_list[-1].bind.body |= _f
183-
else f
184-
end
185-
)
164+
f
186165
elif .op then
187166
.right |= _f
188167
else f

0 commit comments

Comments
 (0)