diff options
author | Adam Joseph <adam@westernsemico.com> | 2023-12-12T11·39-0800 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-12-12T17·49+0000 |
commit | 2565a21aa9e88465c78634c763c9a34a2332f4f6 (patch) | |
tree | 05e2423a2a3ebfcb5f3d222055f3599ff904ec64 /tvix/eval/src | |
parent | 331d9ee54ad2b60e20c628359832dd60a1785d6d (diff) |
fix(tvix/eval): builtins.length: propagate catchables r/7203
This commit fixes out builtins.length so it propagates catchables like cppnix does. Change-Id: I7670bec5eee1d4cd3f67a04c9a6808979fb56a8d Reviewed-on: https://cl.tvl.fyi/c/depot/+/10315 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: Adam Joseph <adam@westernsemico.com> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src')
3 files changed, 5 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 4844ae8f1b53..c2618a4066f4 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -665,6 +665,9 @@ mod pure_builtins { #[builtin("length")] async fn builtin_length(co: GenCo, list: Value) -> Result<Value, ErrorKind> { + if list.is_catchable() { + return Ok(list); + } Ok(Value::Integer(list.to_list()?.len() as i64)) } diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp new file mode 100644 index 000000000000..c508d5366f70 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.exp @@ -0,0 +1 @@ +false diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix new file mode 100644 index 000000000000..037a4911acb1 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-length-catchable.nix @@ -0,0 +1 @@ +(builtins.tryEval (builtins.length (throw "fred"))).success |