From ddb7bc8d18bd11deb87a70ec300a281aaf34c2c7 Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Thu, 8 Feb 2024 16:40:24 -0500 Subject: fix(tvix): Catch errors for generator in some builtins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nix doesn't propagate errors for the function argument to some builtins, like genList and map: ❯ nix repl Welcome to Nix version 2.3.17. Type :? for help. nix-repl> (builtins.tryEval (builtins.genList (builtins.throw "a") 10)).success true nix-repl> (builtins.tryEval (builtins.map (builtins.throw "a") [ "" ])).success true Note that this is untested as of this particular commit, only because a big test suite covering all sorts of catchable error propagation issues is coming next Change-Id: I48c8eb390a541204b1a6d438c753fa1ca9b3877e Reviewed-on: https://cl.tvl.fyi/c/depot/+/10753 Autosubmit: aspen Tested-by: BuildkiteCI Reviewed-by: raitobezarius --- tvix/eval/src/builtins/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tvix/eval/src') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index a3b32e9e02..716da4d041 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -524,7 +524,8 @@ mod pure_builtins { #[builtin("genList")] async fn builtin_gen_list( co: GenCo, - generator: Value, + // Nix 2.3 doesn't propagate failures here + #[catch] generator: Value, length: Value, ) -> Result { let mut out = imbl::Vector::::new(); @@ -911,7 +912,7 @@ mod pure_builtins { } #[builtin("map")] - async fn builtin_map(co: GenCo, f: Value, list: Value) -> Result { + async fn builtin_map(co: GenCo, #[catch] f: Value, list: Value) -> Result { let mut out = imbl::Vector::::new(); // the best span we can get… -- cgit 1.4.1