From 489395448f0fbe268c6503018012992e1e6cfc22 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 21 Sep 2022 01:10:22 +0300 Subject: feat(tvix/eval): track other type in NotCallable error kind This makes for slightly nicer error messages if something isn't, well, callable. Change-Id: I821c8d7447b93aea9ccaaa52ed329de0cca4b18e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6718 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/errors.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tvix/eval/src/errors.rs') diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 17b236d038..83496b59df 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", -- cgit 1.4.1