about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2024-02-02T20·49-0500
committeraspen <root@gws.fyi>2024-02-08T19·59+0000
commitb77a103a2ad0768f3892a7e2e38d0e8c79c09034 (patch)
tree49e9d48fa94bb323500130e92a2727955c7087d4 /tvix
parent780b47193a19ec34d467776b142d115bd0029dff (diff)
fix(tvix/eval): Propagate catchables in a few more places r/7483
Propagate catchables that we get from forcing thunks in builtins in a
few more places using the new try_value! macro

Change-Id: I95fd41a231f877ff153f4adbabd944372d4cc7eb
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10738
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/builtins/mod.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index de21ccd5b1a7..a3b32e9e02ce 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -249,7 +249,7 @@ mod pure_builtins {
         let mut out = imbl::Vector::new();
 
         for value in lists.to_list()? {
-            let list = generators::request_force(&co, value).await.to_list()?;
+            let list = try_value!(generators::request_force(&co, value).await).to_list()?;
             out.extend(list.into_iter());
         }
 
@@ -262,7 +262,7 @@ mod pure_builtins {
         let mut res = imbl::Vector::new();
         for val in list {
             let out = generators::request_call_with(&co, f.clone(), [val]).await;
-            let out = generators::request_force(&co, out).await;
+            let out = try_value!(generators::request_force(&co, out).await);
             res.extend(out.to_list()?);
         }
         Ok(Value::List(res.into()))
@@ -898,10 +898,11 @@ mod pure_builtins {
         let list = list.to_list()?;
         let mut map = BTreeMap::new();
         for val in list {
-            let attrs = generators::request_force(&co, val).await.to_attrs()?;
-            let name = generators::request_force(&co, attrs.select_required("name")?.clone())
-                .await
-                .to_str()?;
+            let attrs = try_value!(generators::request_force(&co, val).await).to_attrs()?;
+            let name = try_value!(
+                generators::request_force(&co, attrs.select_required("name")?.clone()).await
+            )
+            .to_str()?;
             let value = attrs.select_required("value")?.clone();
             // Map entries earlier in the list take precedence over entries later in the list
             map.entry(name).or_insert(value);
@@ -1023,7 +1024,7 @@ mod pure_builtins {
         for elem in list {
             let result = generators::request_call_with(&co, pred.clone(), [elem.clone()]).await;
 
-            if generators::request_force(&co, result).await.as_bool()? {
+            if try_value!(generators::request_force(&co, result).await).as_bool()? {
                 right.push_back(elem);
             } else {
                 wrong.push_back(elem);
@@ -1069,12 +1070,12 @@ mod pure_builtins {
     ) -> Result<Value, ErrorKind> {
         let from = from.to_list()?;
         for val in &from {
-            generators::request_force(&co, val.clone()).await;
+            try_value!(generators::request_force(&co, val.clone()).await);
         }
 
         let to = to.to_list()?;
         for val in &to {
-            generators::request_force(&co, val.clone()).await;
+            try_value!(generators::request_force(&co, val.clone()).await);
         }
 
         let mut string = s.to_contextful_str()?;