about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/compiler/mod.rs2
-rw-r--r--tvix/eval/src/value/thunk.rs14
2 files changed, 8 insertions, 8 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index a1f11501a449..2ae010ada6ed 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -877,7 +877,7 @@ impl Compiler {
         // Emit the thunk directly if it does not close over the
         // environment.
         if thunk.lambda.upvalue_count == 0 {
-            self.emit_constant(Value::Thunk(Thunk::new(thunk.lambda)));
+            self.emit_constant(Value::Thunk(Thunk::new(Rc::new(thunk.lambda))));
             return;
         }
 
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 15179388dc86..57c38e089460 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -27,13 +27,10 @@ use super::Lambda;
 /// Internal representation of the different states of a thunk.
 #[derive(Debug)]
 enum ThunkRepr {
-    /// Thunk is suspended and awaiting execution.
-    Suspended { lambda: Lambda },
-
     /// Thunk is closed over some values, suspended and awaiting
     /// execution.
-    ClosedSuspended {
-        lambda: Lambda,
+    Suspended {
+        lambda: Rc<Lambda>,
         upvalues: Vec<Value>,
     },
 
@@ -49,7 +46,10 @@ enum ThunkRepr {
 pub struct Thunk(Rc<RefCell<ThunkRepr>>);
 
 impl Thunk {
-    pub fn new(lambda: Lambda) -> Self {
-        Thunk(Rc::new(RefCell::new(ThunkRepr::Suspended { lambda })))
+    pub fn new(lambda: Rc<Lambda>) -> Self {
+        Thunk(Rc::new(RefCell::new(ThunkRepr::Suspended {
+            lambda,
+            upvalues: vec![],
+        })))
     }
 }