From 33ab1fdbdda4e95e48b767a3f7f8f66413b6de0e Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 1 Dec 2022 15:05:57 +0100 Subject: Fix closure capturing bug with for loops --- src/model/func.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/model/func.rs') 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"]); -- cgit v1.2.3