Refactor Destructure to handle assignments

Renames `DefDestructure` to `Destructure` to better reflect its use in
both definitions and assignments.
Introduces `bind_assign_pattern` to handle assignment destructuring in
the binder.
Adds `test_assign_destructuring` to verify assignment destructuring
functionality.
This commit is contained in:
Michael Schimmel
2026-02-24 08:51:24 +01:00
parent 2b0e7f49d7
commit 51d83562de
9 changed files with 162 additions and 16 deletions
+5 -5
View File
@@ -82,8 +82,8 @@ pub enum BoundKind<T = ()> {
value: Box<BoundNode<T>>,
},
/// A destructuring definition (can be local or global depending on the pattern)
DefDestructure {
/// A destructuring operation (can be a definition or an assignment depending on the pattern)
Destructure {
pattern: Box<BoundNode<T>>,
value: Box<BoundNode<T>>,
},
@@ -194,11 +194,11 @@ where
},
) => na == nb && ga == gb && va == vb,
(
BoundKind::DefDestructure {
BoundKind::Destructure {
pattern: pa,
value: va,
},
BoundKind::DefDestructure {
BoundKind::Destructure {
pattern: pb,
value: vb,
},
@@ -265,7 +265,7 @@ impl<T> BoundKind<T> {
BoundKind::DefGlobal {
name, global_index, ..
} => format!("DEF_GLOBAL({}, Idx:{})", name.name, global_index),
BoundKind::DefDestructure { .. } => "DEF_DESTRUCTURE".to_string(),
BoundKind::Destructure { .. } => "DESTRUCTURE".to_string(),
BoundKind::Lambda {
params, upvalues, ..
} => {