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/tests/tvix_tests/eval-okay-thunked-functor.exp1
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.nix7
-rw-r--r--tvix/eval/src/vm.rs4
3 files changed, 12 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.exp
new file mode 100644
index 000000000000..d81cc0710eb6
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.exp
@@ -0,0 +1 @@
+42
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.nix
new file mode 100644
index 000000000000..f8eba2ac2fc0
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-functor.nix
@@ -0,0 +1,7 @@
+let
+  __functor = f;
+  f = self: x: self.out * x;
+in {
+  inherit __functor;
+  out = 21;
+} 2
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 818b5ff9b1f7..93bf853f9c26 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -406,6 +406,10 @@ impl<'o> VM<'o> {
             Value::Attrs(ref attrs) => match attrs.select("__functor") {
                 None => Err(self.error(ErrorKind::NotCallable(callable.type_of()))),
                 Some(functor) => {
+                    if let Value::Thunk(thunk) = &functor {
+                        fallible!(self, thunk.force(self));
+                    }
+
                     // The functor receives the set itself as its first argument
                     // and needs to be called with it. However, this call is
                     // synthetic (i.e. there is no corresponding OpCall for the