feat(tvix/eval): Support builtins.head
TL;DR: - support `builtins.head` - define `ErrorKind::IndexOutOfBounds` and canonical error code - support basic unit tests Change-Id: I859107ffb4e220cba1be8c2ac41d1913dcca37ff Reviewed-on: https://cl.tvl.fyi/c/depot/+/6544 Reviewed-by: wpcarro <wpcarro@gmail.com> Autosubmit: wpcarro <wpcarro@gmail.com> Reviewed-by: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
0595870341
commit
85b3f17007
5 changed files with 27 additions and 0 deletions
|
|
@ -25,6 +25,11 @@ pub enum ErrorKind {
|
|||
name: String,
|
||||
},
|
||||
|
||||
// Attempted to index into a list beyond its boundaries.
|
||||
IndexOutOfBounds {
|
||||
index: usize,
|
||||
},
|
||||
|
||||
TypeError {
|
||||
expected: &'static str,
|
||||
actual: &'static str,
|
||||
|
|
@ -123,6 +128,10 @@ impl Error {
|
|||
name
|
||||
),
|
||||
|
||||
ErrorKind::IndexOutOfBounds { index } => {
|
||||
format!("list index '{}' is out of bounds", index)
|
||||
}
|
||||
|
||||
ErrorKind::TypeError { expected, actual } => format!(
|
||||
"expected value of type '{}', but found a '{}'",
|
||||
expected, actual
|
||||
|
|
@ -208,6 +217,7 @@ to a missing value in the attribute set(s) included via `with`."#,
|
|||
ErrorKind::DuplicateAttrsKey { .. } => "E016",
|
||||
ErrorKind::ThunkForce(_) => "E017",
|
||||
ErrorKind::NotCoercibleToString { .. } => "E018",
|
||||
ErrorKind::IndexOutOfBounds { .. } => "E019",
|
||||
ErrorKind::NotImplemented(_) => "E999",
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue