about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/builtins/mod.rs9
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-compare-ordering-catchable.exp (renamed from tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-compare-ordering-catchable.exp)0
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-compare-ordering-catchable.nix (renamed from tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-compare-ordering-catchable.nix)0
-rw-r--r--tvix/eval/src/value/mod.rs10
-rw-r--r--tvix/eval/src/vm/macros.rs5
5 files changed, 15 insertions, 9 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 1a34ea5dfbac..09b341886c59 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -611,10 +611,11 @@ mod pure_builtins {
     #[builtin("lessThan")]
     async fn builtin_less_than(co: GenCo, x: Value, y: Value) -> Result<Value, ErrorKind> {
         let span = generators::request_span(&co).await;
-        Ok(Value::Bool(matches!(
-            x.nix_cmp_ordering(y, co, span).await?,
-            Ordering::Less
-        )))
+        match x.nix_cmp_ordering(y, co, span).await? {
+            Err(cek) => Ok(Value::Catchable(cek)),
+            Ok(Ordering::Less) => Ok(Value::Bool(true)),
+            Ok(_) => Ok(Value::Bool(false)),
+        }
     }
 
     #[builtin("listToAttrs")]
diff --git a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-compare-ordering-catchable.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-ordering-catchable.exp
index c508d5366f70..c508d5366f70 100644
--- a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-compare-ordering-catchable.exp
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-ordering-catchable.exp
diff --git a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-compare-ordering-catchable.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-ordering-catchable.nix
index 9000160e57fe..9000160e57fe 100644
--- a/tvix/eval/src/tests/tvix_tests/notyetpassing/eval-okay-compare-ordering-catchable.nix
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-compare-ordering-catchable.nix
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 7b64e9fc8f93..9be57d43f561 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -616,7 +616,7 @@ impl Value {
         other: Self,
         co: GenCo,
         span: LightSpan,
-    ) -> Result<Ordering, ErrorKind> {
+    ) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind> {
         Self::nix_cmp_ordering_(self, other, co, span).await
     }
 
@@ -625,7 +625,7 @@ impl Value {
         other: Self,
         co: GenCo,
         span: LightSpan,
-    ) -> Result<Ordering, ErrorKind> {
+    ) -> Result<Result<Ordering, CatchableErrorKind>, ErrorKind> {
         // this is a stack of ((v1,v2),peq) triples to be compared;
         // after each triple is popped off of the stack, v1 is
         // compared to v2 using peq-mode PointerEquality
@@ -636,7 +636,7 @@ impl Value {
                 abp
             } else {
                 // stack is empty, so they are equal
-                return Ok(Ordering::Equal);
+                return Ok(Ok(Ordering::Equal));
             };
             if ptr_eq == PointerEquality::AllowAll {
                 if a.clone()
@@ -650,6 +650,8 @@ impl Value {
                 b = b.force(&co, span.clone()).await?;
             }
             let result = match (a, b) {
+                (Value::Catchable(c), _) => return Ok(Err(c)),
+                (_, Value::Catchable(c)) => return Ok(Err(c)),
                 // same types
                 (Value::Integer(i1), Value::Integer(i2)) => i1.cmp(&i2),
                 (Value::Float(f1), Value::Float(f2)) => f1.total_cmp(&f2),
@@ -682,7 +684,7 @@ impl Value {
                 }
             };
             if result != Ordering::Equal {
-                return Ok(result);
+                return Ok(Ok(result));
             }
         }
     }
diff --git a/tvix/eval/src/vm/macros.rs b/tvix/eval/src/vm/macros.rs
index 34e94bb5fa74..eb386df92fa3 100644
--- a/tvix/eval/src/vm/macros.rs
+++ b/tvix/eval/src/vm/macros.rs
@@ -44,7 +44,10 @@ macro_rules! cmp_op {
             let b = generators::request_force(&co, b).await;
             let span = generators::request_span(&co).await;
             let ordering = a.nix_cmp_ordering(b, co, span).await?;
-            Ok(Value::Bool(cmp_op!(@order $op ordering)))
+            match ordering {
+                Err(cek) => Ok(Value::Catchable(cek)),
+                Ok(ordering) => Ok(Value::Bool(cmp_op!(@order $op ordering))),
+            }
         }
 
         let gen_span = $frame.current_light_span();