about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/builtins/mod.rs3
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp1
-rw-r--r--tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix1
3 files changed, 5 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 4844ae8f1b53..c2618a4066f4 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -665,6 +665,9 @@ mod pure_builtins {
 
     #[builtin("length")]
     async fn builtin_length(co: GenCo, list: Value) -> Result<Value, ErrorKind> {
+        if list.is_catchable() {
+            return Ok(list);
+        }
         Ok(Value::Integer(list.to_list()?.len() as i64))
     }
 
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp
new file mode 100644
index 000000000000..c508d5366f70
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp
@@ -0,0 +1 @@
+false
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix
new file mode 100644
index 000000000000..037a4911acb1
--- /dev/null
+++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix
@@ -0,0 +1 @@
+(builtins.tryEval (builtins.length (throw "fred"))).success