From fefa8c55c45d82fc1d81e02a96e126812e1e1223 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 5 Sep 2022 11:42:53 -0700 Subject: feat(tvix/eval): Support builtins.tail TL;DR: - support `builtins.tail` - define `ErrorKind::TailEmptyList` and canonical error code - support basic unit tests Unsure whether or not the error should be a dedicated `ErrorKind`... Change-Id: Iae90fda1bb21ce7bdb1aaa2aeb2b8c1e6dcb0f05 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6545 Reviewed-by: wpcarro Autosubmit: wpcarro Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/errors.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix/eval/src/errors.rs') diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 6331ee64be..10bc9276ad 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -31,6 +31,9 @@ pub enum ErrorKind { index: i64, }, + /// Attempted to call `builtins.tail` on an empty list. + TailEmptyList, + TypeError { expected: &'static str, actual: &'static str, @@ -150,6 +153,8 @@ impl Error { format!("list index '{}' is out of bounds", index) } + ErrorKind::TailEmptyList => format!("'tail' called on an empty list"), + ErrorKind::TypeError { expected, actual } => format!( "expected value of type '{}', but found a '{}'", expected, actual @@ -257,6 +262,7 @@ to a missing value in the attribute set(s) included via `with`."#, ErrorKind::NotAnAbsolutePath(_) => "E020", ErrorKind::ParseIntError(_) => "E021", ErrorKind::NegativeLength { .. } => "E022", + ErrorKind::TailEmptyList { .. } => "E023", ErrorKind::NotImplemented(_) => "E999", } } -- cgit 1.4.1