diff options
author | Aspen Smith <root@gws.fyi> | 2024-02-08T21·40-0500 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-02-08T21·58+0000 |
commit | ddb7bc8d18bd11deb87a70ec300a281aaf34c2c7 (patch) | |
tree | 89709b6f27f07d1e44d595dccf19c67c761fe9c7 /tvix/eval/src/builtins | |
parent | 17036718df7f68c40779e15aced2cffbd92d20fa (diff) |
fix(tvix): Catch errors for generator in some builtins r/7487
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 <root@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index a3b32e9e02ce..716da4d04156 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<Value, ErrorKind> { let mut out = imbl::Vector::<Value>::new(); @@ -911,7 +912,7 @@ mod pure_builtins { } #[builtin("map")] - async fn builtin_map(co: GenCo, f: Value, list: Value) -> Result<Value, ErrorKind> { + async fn builtin_map(co: GenCo, #[catch] f: Value, list: Value) -> Result<Value, ErrorKind> { let mut out = imbl::Vector::<Value>::new(); // the best span we can get… |