Simplify tuple flattening and destructuring
The `flatten_tuple` function was unnecessarily recursive. It can now simply return the elements of the tuple directly. The VM's destructuring logic has been updated to handle nested destructuring more efficiently. A new integration test case for multi-level destructuring has been added.
This commit is contained in:
@@ -308,13 +308,7 @@ impl Specializer {
|
||||
|
||||
fn flatten_tuple(&self, node: AnalyzedNode) -> Vec<AnalyzedNode> {
|
||||
match node.kind {
|
||||
BoundKind::Tuple { elements } => {
|
||||
let mut flat = Vec::new();
|
||||
for el in elements {
|
||||
flat.extend(self.flatten_tuple(el));
|
||||
}
|
||||
flat
|
||||
}
|
||||
BoundKind::Tuple { elements } => elements,
|
||||
_ => vec![node],
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user