diff options
Diffstat (limited to 'src/eval/capture.rs')
| -rw-r--r-- | src/eval/capture.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/eval/capture.rs b/src/eval/capture.rs index 4e8d7604..8e54122f 100644 --- a/src/eval/capture.rs +++ b/src/eval/capture.rs @@ -88,6 +88,14 @@ impl<'a> CapturesVisitor<'a> { self.bind(expr.binding()); } + // A show rule contains a binding, but that binding is only active + // after the target has been evaluated. + Some(Expr::Show(show)) => { + self.visit(show.target().as_red()); + self.bind(show.binding()); + self.visit(show.body().as_red()); + } + // A for loop contains one or two bindings in its pattern. These are // active after the iterable is evaluated but before the body is // evaluated. @@ -162,6 +170,11 @@ mod tests { test("{(..x) => x + y}", &["y"]); test("{(x, y: x + z) => x + y}", &["x", "z"]); + // Show rule. + test("#show x: y as x", &["y"]); + test("#show x: y as x + z", &["y", "z"]); + test("#show x: x as x", &["x"]); + // For loop. test("#for x in y { x + z }", &["y", "z"]); test("#for x, y in y { x + y }", &["y"]); |
