Skip to content

Commit

Permalink
Run RHS of pattern binding with original input.
Browse files Browse the repository at this point in the history
  • Loading branch information
01mf02 committed Oct 28, 2024
1 parent b210900 commit 4560c86
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions jaq-core/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,10 @@ impl<F: FilterT<F>> FilterT<F> for Id {
// `l as $x | r`, `l as [...] | r`, or `l as {...} | r`
Ast::Pipe(l, Some(pat), r) => l.pipe(lut, cv, move |(ctx, v), y| match pat {
Pattern::Var => r.run(lut, (ctx.cons_var(y), v)),
Pattern::Idx(pats) => flat_map_then_with(
bind_pats(pats, lut, ctx.clone(), (ctx, y.clone())),
y,
|ctx, y| r.run(lut, (ctx, y)),
),
Pattern::Idx(pats) => {
let r = |ctx, v| r.run(lut, (ctx, v));
flat_map_then_with(bind_pats(pats, lut, ctx.clone(), (ctx, y)), v, r)
}
}),

Ast::Comma(l, r) => Box::new(l.run(lut, cv.clone()).chain(lazy(|| r.run(lut, cv)))),
Expand Down

0 comments on commit 4560c86

Please sign in to comment.