fix: thunk & function

This commit is contained in:
2025-05-15 11:11:11 +08:00
parent bcb6c48cfa
commit 2293b9e2de
10 changed files with 76 additions and 112 deletions

View File

@@ -42,23 +42,18 @@ impl<'vm> AttrSet<'vm> {
self.data.get(&sym).is_some()
}
pub fn capture(&mut self, env: Rc<Env<'vm>>) {
self.data = self
pub fn capture(&mut self, env: &Rc<Env<'vm>>) {
self
.data
.into_iter()
.map(|(k, v)| {
(
k.clone(),
.iter()
.for_each(|(_, v)| {
match v.clone() {
x @ Value::ThunkRef(thunk) => {
Value::Thunk(ref thunk) => {
thunk.capture(env.clone());
x
}
x => x,
},
)
_ => ()
}
})
.collect();
}
pub fn update(mut self, other: AttrSet<'vm>) -> AttrSet<'vm> {
@@ -83,7 +78,7 @@ impl<'vm> AttrSet<'vm> {
&self.data
}
pub fn force_deep(&mut self, vm: &VM<'vm, '_>) -> Result<()> {
pub fn force_deep(&mut self, vm: &'vm VM<'_>) -> Result<()> {
let mut map: Vec<_> = self
.data
.into_iter()
@@ -170,7 +165,7 @@ impl<'vm> RecAttrSet<'vm> {
RecAttrSet { data }
}
pub fn force_deep(&mut self, vm: &VM<'vm, '_>) -> Result<()> {
pub fn force_deep(&mut self, vm: &'vm VM<'_>) -> Result<()> {
let mut map: Vec<_> = self
.data
.map