about summary refs log tree commit diff
path: root/tvix/eval/src/value/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/value/mod.rs')
-rw-r--r--tvix/eval/src/value/mod.rs20
1 files changed, 3 insertions, 17 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index fb02dfc3673a..1ee98c25b2cc 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -16,7 +16,6 @@ mod thunk;
 
 use crate::errors::ErrorKind;
 use crate::opcode::StackIdx;
-use crate::upvalues::UpvalueCarrier;
 use crate::vm::VM;
 pub use attrs::NixAttrs;
 pub use builtin::Builtin;
@@ -155,22 +154,9 @@ impl Value {
                     (Some(f), _) => {
                         // use a closure here to deal with the thunk borrow we need to do below
                         let call_to_string = |value: &Value, vm: &mut VM| {
-                            // TODO(sterni): calling logic should be extracted into a helper
-                            let result = match value {
-                                Value::Closure(c) => {
-                                    vm.push(self.clone());
-                                    vm.call(c.lambda(), c.upvalues().clone(), 1)
-                                        .map_err(|e| e.kind)
-                                }
-
-                                Value::Builtin(b) => {
-                                    vm.push(self.clone());
-                                    vm.call_builtin(b.clone()).map_err(|e| e.kind)?;
-                                    Ok(vm.pop())
-                                }
-
-                                _ => Err(ErrorKind::NotCallable),
-                            }?;
+                            // Leave self on the stack as an argument to the function call.
+                            vm.push(self.clone());
+                            let result = vm.call_value(value)?;
 
                             match result {
                                 Value::String(s) => Ok(s),