summaryrefslogtreecommitdiff
path: root/src/model/func.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-12-01 15:05:57 +0100
committerLaurenz <laurmaedje@gmail.com>2022-12-02 13:08:06 +0100
commit33ab1fdbdda4e95e48b767a3f7f8f66413b6de0e (patch)
tree4481ae8f0bf11a71b6002561d1ab6f43a4d52a23 /src/model/func.rs
parente1e93938a148402d67cb06c25c674aa973598b03 (diff)
Fix closure capturing bug with for loops
Diffstat (limited to 'src/model/func.rs')
-rw-r--r--src/model/func.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/model/func.rs b/src/model/func.rs
index dcb82027..60f36bd4 100644
--- a/src/model/func.rs
+++ b/src/model/func.rs
@@ -329,12 +329,14 @@ impl<'a> CapturesVisitor<'a> {
// evaluated.
Some(ast::Expr::For(expr)) => {
self.visit(expr.iter().as_untyped());
+ self.internal.enter();
let pattern = expr.pattern();
if let Some(key) = pattern.key() {
self.bind(key);
}
self.bind(pattern.value());
self.visit(expr.body().as_untyped());
+ self.internal.exit();
}
// An import contains items, but these are active only after the
@@ -416,6 +418,7 @@ mod tests {
// For loop.
test("#for x in y { x + z }", &["y", "z"]);
test("#for x, y in y { x + y }", &["y"]);
+ test("#for x in y {} #x", &["x", "y"]);
// Import.
test("#import x, y from z", &["z"]);