diff options
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r-- | tvix/eval/src/vm.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs index 3e8509187b4d..c833d7b191d7 100644 --- a/tvix/eval/src/vm.rs +++ b/tvix/eval/src/vm.rs @@ -158,6 +158,21 @@ impl VM { self.push(Value::Attrs(Rc::new(lhs.update(&rhs)))) } + OpCode::OpAttrsSelect => { + let key = self.pop().as_string()?; + let attrs = self.pop().as_attrs()?; + + match attrs.select(key.as_str()) { + Some(value) => self.push(value.clone()), + + None => { + return Err(Error::AttributeNotFound { + name: key.as_str().to_string(), + }) + } + } + } + OpCode::OpList(count) => { let list = NixList::construct(count, self.stack.split_off(self.stack.len() - count)); |