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/errors.rs11
-rw-r--r--tvix/eval/src/vm.rs4
2 files changed, 9 insertions, 6 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index 17b236d0385f..83496b59df33 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -60,7 +60,7 @@ pub enum ErrorKind {
     VariableAlreadyDefined(Span),
 
     /// Attempt to call something that is not callable.
-    NotCallable,
+    NotCallable(&'static str),
 
     /// Infinite recursion encountered while forcing thunks.
     InfiniteRecursion,
@@ -191,8 +191,11 @@ to a missing value in the attribute set(s) included via `with`."#,
 
             ErrorKind::VariableAlreadyDefined(_) => "variable has already been defined".to_string(),
 
-            ErrorKind::NotCallable => {
-                "this value is not callable (i.e. not a function or builtin)".to_string()
+            ErrorKind::NotCallable(other_type) => {
+                format!(
+                    "only functions and builtins can be called, but this is a '{}'",
+                    other_type
+                )
             }
 
             ErrorKind::InfiniteRecursion => "infinite recursion encountered".to_string(),
@@ -261,7 +264,7 @@ to a missing value in the attribute set(s) included via `with`."#,
             ErrorKind::UnknownStaticVariable => "E010",
             ErrorKind::UnknownDynamicVariable(_) => "E011",
             ErrorKind::VariableAlreadyDefined(_) => "E012",
-            ErrorKind::NotCallable => "E013",
+            ErrorKind::NotCallable(_) => "E013",
             ErrorKind::InfiniteRecursion => "E014",
             ErrorKind::ParseErrors(_) => "E015",
             ErrorKind::DuplicateAttrsKey { .. } => "E016",
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 69ffc7d5c293..87adfe5611a4 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -193,7 +193,7 @@ impl<'o> VM<'o> {
             Value::Thunk(t) => self.call_value(&t.value()),
 
             // TODO: this isn't guaranteed to be a useful span, actually
-            _ => Err(self.error(ErrorKind::NotCallable)),
+            other => Err(self.error(ErrorKind::NotCallable(other.type_of()))),
         }
     }
 
@@ -499,7 +499,7 @@ impl<'o> VM<'o> {
                             frame.ip = CodeIdx(0); // reset instruction pointer to beginning
                         }
 
-                        _ => return Err(self.error(ErrorKind::NotCallable)),
+                        _ => return Err(self.error(ErrorKind::NotCallable(callable.type_of()))),
                     }
                 }