feat(tvix/eval): implement ? operator (single-level only)
This makes it possible to check things like `{} ? a` with a single
level of nesting.
Change-Id: I567c36fcfd2f9e2f60071acd3ebfe56dea59b26f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6161
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
parent
e8c4e26b41
commit
cf3e3b784b
3 changed files with 50 additions and 7 deletions
|
|
@ -173,6 +173,13 @@ impl VM {
|
|||
}
|
||||
}
|
||||
|
||||
OpCode::OpAttrsIsSet => {
|
||||
let key = self.pop().as_string()?;
|
||||
let attrs = self.pop().as_attrs()?;
|
||||
let result = Value::Bool(attrs.select(key.as_str()).is_some());
|
||||
self.push(result);
|
||||
}
|
||||
|
||||
OpCode::OpList(count) => {
|
||||
let list =
|
||||
NixList::construct(count, self.stack.split_off(self.stack.len() - count));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue