fix(tvix): Catch errors for generator in some builtins
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>
This commit is contained in:
parent
17036718df
commit
ddb7bc8d18
1 changed files with 3 additions and 2 deletions
|
|
@ -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…
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue