From 243a4b569909be678e0ddfcc1c66c62ff3ddb487 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Tue, 12 Dec 2023 04:33:34 -0800 Subject: fix(tvix/eval): substring: propagate catchables Change-Id: Ia9b7858c817fbc9c95a3d1c2855b2445f7830e8d Reviewed-on: https://cl.tvl.fyi/c/depot/+/10326 Tested-by: BuildkiteCI Autosubmit: Adam Joseph Reviewed-by: tazjin --- tvix/eval/src/builtins/mod.rs | 9 +++++---- .../tvix_tests/eval-okay-substring-propagate-catchables.exp | 1 + .../tvix_tests/eval-okay-substring-propagate-catchables.nix | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.nix (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 554fc9d7e329..27b7d5648f48 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -1002,10 +1002,11 @@ mod pure_builtins { let beg = start.as_int()?; let len = len.as_int()?; let span = generators::request_span(&co).await; - let x = s - .coerce_to_string(co, CoercionKind::Weak, span) - .await? - .to_str()?; + let x = s.coerce_to_string(co, CoercionKind::Weak, span).await?; + if x.is_catchable() { + return Ok(x); + } + let x = x.to_str()?; if beg < 0 { return Err(ErrorKind::IndexOutOfBounds { index: beg }); diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.exp new file mode 100644 index 000000000000..c508d5366f70 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.exp @@ -0,0 +1 @@ +false diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.nix new file mode 100644 index 000000000000..c5a6f5a8203c --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-substring-propagate-catchables.nix @@ -0,0 +1 @@ +(builtins.tryEval ( builtins.substring 0 4 (throw "jill") )).success -- cgit 1.4.1