diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-04-23 21:55:58 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-04-23 21:55:58 +0200 |
| commit | 04fb8b288aa7c80607da79db7d085a4820b95a9d (patch) | |
| tree | 7ca96d09d511274ebac298c329d5eef53a290d9c /src/eval/capture.rs | |
| parent | 7a2cc3e7d29d16c5cf9b5a93a688e14da93c8662 (diff) | |
Show rules with type ascribed object
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"]); |
