diff options
author | Ryan Lahfa <tvl@lahfa.xyz> | 2023-12-30T02·21+0100 |
---|---|---|
committer | raitobezarius <tvl@lahfa.xyz> | 2024-01-14T03·37+0000 |
commit | 2750e1e640f5228afe1efcdb4deb4922887d0121 (patch) | |
tree | 1dccb67909d8a951ec49f5302ff1b5ad6e9fd11d /tvix/eval/src/value | |
parent | 37cc88897e0c6baa9835b49842e723f9e7006f5f (diff) |
fix(tvix/eval): catchable-aware builtins r/7379
A bunch of operations in Tvix are not aware of catchable values and does not propagate them. In the meantime, as we wait for a better solution, we just offer this commit for moving the needle. Change-Id: Ic3f0e1550126b0847b597dfc1402c35e0eeef469 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10473 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/value')
-rw-r--r-- | tvix/eval/src/value/json.rs | 12 | ||||
-rw-r--r-- | tvix/eval/src/value/mod.rs | 23 |
2 files changed, 22 insertions, 13 deletions
diff --git a/tvix/eval/src/value/json.rs b/tvix/eval/src/value/json.rs index fb9750a9fe4a..8c31bd0e6082 100644 --- a/tvix/eval/src/value/json.rs +++ b/tvix/eval/src/value/json.rs @@ -34,7 +34,10 @@ impl Value { let mut out = vec![]; for val in l.into_iter() { - out.push(generators::request_to_json(co, val).await); + match generators::request_to_json(co, val).await { + Ok(v) => out.push(v), + Err(cek) => return Ok(Err(cek)), + } } Json::Array(out) @@ -67,14 +70,17 @@ impl Value { // serialise to a JSON serialisation of that inner // value (regardless of what it is!). if let Some(out_path) = attrs.select("outPath") { - return Ok(Ok(generators::request_to_json(co, out_path.clone()).await)); + return Ok(generators::request_to_json(co, out_path.clone()).await); } let mut out = Map::with_capacity(attrs.len()); for (name, value) in attrs.into_iter_sorted() { out.insert( name.as_str().to_string(), - generators::request_to_json(co, value).await, + match generators::request_to_json(co, value).await { + Ok(v) => v, + Err(cek) => return Ok(Err(cek)), + }, ); } diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs index 1558d2cc9c24..ccca0bea5b2e 100644 --- a/tvix/eval/src/value/mod.rs +++ b/tvix/eval/src/value/mod.rs @@ -589,16 +589,19 @@ impl Value { .context("comparing derivations")? .clone(); - let result = out1 - .clone() - .force(co, span.clone()) - .await? - .to_contextful_str()? - == out2 - .clone() - .force(co, span.clone()) - .await? - .to_contextful_str()?; + let out1 = out1.clone().force(co, span.clone()).await?; + let out2 = out2.clone().force(co, span.clone()).await?; + + if out1.is_catchable() { + return Ok(out1); + } + + if out2.is_catchable() { + return Ok(out2); + } + + let result = + out1.to_contextful_str()? == out2.to_contextful_str()?; if !result { return Ok(Value::Bool(false)); } else { |