diff options
| author | Marmare314 <49279081+Marmare314@users.noreply.github.com> | 2023-04-06 15:26:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-06 15:26:09 +0200 |
| commit | 0f8219b392e96d3cf7d784ee5d474274169d9918 (patch) | |
| tree | 60ce53bb076b61b09184f4f1aefa2fa63ebb3ed2 /src/eval/func.rs | |
| parent | a73149767c82509b77ccf6996ab0b1125cc9c249 (diff) | |
Unpacking syntax (#532)
Closes #341
Diffstat (limited to 'src/eval/func.rs')
| -rw-r--r-- | src/eval/func.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/eval/func.rs b/src/eval/func.rs index e6402e87..93da6d7b 100644 --- a/src/eval/func.rs +++ b/src/eval/func.rs @@ -441,7 +441,10 @@ impl<'a> CapturesVisitor<'a> { if let Some(init) = expr.init() { self.visit(init.as_untyped()); } - self.bind(expr.binding()); + + for ident in expr.kind().idents() { + self.bind(ident); + } } // A for loop contains one or two bindings in its pattern. These are @@ -450,11 +453,12 @@ impl<'a> CapturesVisitor<'a> { 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); + for ident in pattern.idents() { + self.bind(ident); } - self.bind(pattern.value()); + self.visit(expr.body().as_untyped()); self.internal.exit(); } @@ -550,7 +554,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, y) in y { x + y }", &["y"]); test("#for x in y {} #x", &["x", "y"]); // Import. |
