From 44d24852c3c62320cb2a4c9b9627e744c518f207 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 10 Jan 2024 23:43:28 +0100 Subject: fix(tvix/eval): catchable-aware `throw` `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 --- tvix/eval/src/builtins/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index eb24c0559f..81d30e91c6 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 { + // 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( -- cgit 1.4.1