about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2024-01-10T22·43+0100
committerraitobezarius <tvl@lahfa.xyz>2024-01-17T17·39+0000
commit44d24852c3c62320cb2a4c9b9627e744c518f207 (patch)
tree62bb81c991814c44a2cbee2e8c99ce6fc09bf9c8 /tvix/eval/src/builtins/mod.rs
parente5e33611d75b333492221e407e485a7dbfb438aa (diff)
fix(tvix/eval): catchable-aware `throw` r/7406
`throw (throw "a")` should work and propagate the internal throw.
Before this commit, it didn't work.

Change-Id: Id5d46f74e484dba99e912ad9fa211f3bf1617bac
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10600
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index eb24c0559f30..81d30e91c689 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -1484,6 +1484,10 @@ mod pure_builtins {
 
     #[builtin("throw")]
     async fn builtin_throw(co: GenCo, message: Value) -> Result<Value, ErrorKind> {
+        // If it's already some error, let's propagate it immediately.
+        if message.is_catchable() {
+            return Ok(message);
+        }
         // TODO(sterni): coerces to string
         // We do not care about the context here explicitly.
         Ok(Value::Catchable(CatchableErrorKind::Throw(