about summary refs log tree commit diff
path: root/tvix/eval/src/value/thunk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value/thunk.rs')
-rw-r--r--tvix/eval/src/value/thunk.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 5107c6328d..1be13bfe89 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -70,7 +70,7 @@ impl Thunk {
     pub fn new_closure(lambda: Rc<Lambda>) -> Self {
         Thunk(Rc::new(RefCell::new(ThunkRepr::Evaluated(Value::Closure(
             Closure {
-                upvalues: Upvalues::with_capacity(lambda.upvalue_count),
+                upvalues: Rc::new(Upvalues::with_capacity(lambda.upvalue_count)),
                 lambda: lambda.clone(),
                 #[cfg(debug_assertions)]
                 is_finalised: false,
@@ -184,7 +184,8 @@ impl Thunk {
                 if *is_finalised {
                     panic!("Thunk::upvalues_mut() called on a finalised closure");
                 }
-                upvalues
+                Rc::get_mut(upvalues)
+                    .expect("upvalues_mut() was called on a thunk which already had multiple references to it")
             }
             thunk => panic!("upvalues() on non-suspended thunk: {thunk:?}"),
         })