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:
William Carroll 2022-09-05 11:41:50 -07:00 committed by clbot
parent 0595870341
commit 85b3f17007
5 changed files with 27 additions and 0 deletions

View file

@ -32,6 +32,10 @@ impl NixList {
self.0.len()
}
pub fn get(&self, i: usize) -> Option<&Value> {
self.0.get(i)
}
pub fn construct(count: usize, stack_slice: Vec<Value>) -> Self {
debug_assert!(
count == stack_slice.len(),