about summary refs log tree commit diff
path: root/tvix/eval/src/builtins
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2022-09-06T21·55-0700
committerclbot <clbot@tvl.fyi>2022-09-22T17·42+0000
commit890bbf9b1fba98ac9791eaacaf594492e7ead662 (patch)
treedbb47ab0ab3a09885a5c6a12648696b7b30e2f47 /tvix/eval/src/builtins
parent9e16d708092e88d0013ef96ef9a33ec28b2c46ea (diff)
feat(tvix/eval): Support builtins.lessThan r/4955
Extend and export the `cmp_op`, and this becomes trivial.

Change-Id: I9c93fa4db0f5a1fc8b56928ea144676f79247de1
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6557
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r--tvix/eval/src/builtins/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index f40c6f9574b1..650cfe674f52 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -16,7 +16,7 @@ use crate::{
     vm::VM,
 };
 
-use crate::arithmetic_op;
+use crate::{arithmetic_op, cmp_op};
 
 use self::versions::{VersionPart, VersionPartsIter};
 
@@ -160,6 +160,11 @@ fn pure_builtins() -> Vec<Builtin> {
                 .map(|list| Value::List(NixList::from(list)))
                 .map_err(Into::into)
         }),
+        Builtin::new(
+            "lessThan",
+            &[false, false],
+            |args, vm| cmp_op!(&*args[0].force(vm)?, &*args[1].force(vm)?, <),
+        ),
         Builtin::new("hasAttr", &[true, true], |args, _| {
             let k = args[0].to_str()?;
             let xs = args[1].to_attrs()?;