From f7907db69d07d9358a269e86237524b0142c23c0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 20 Nov 2022 23:35:53 +0100 Subject: fix(tvix/eval): builtins.listToAttrs must force keys Change-Id: Ief9ebc2285a0c50654c2edd3351432dc1588f9fc Reviewed-on: https://cl.tvl.fyi/c/depot/+/7313 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/builtins/mod.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'tvix/eval') diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 3ceafa498fcd..89e7c37d3f20 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -537,13 +537,8 @@ mod pure_builtins { let mut map = BTreeMap::new(); for val in list { let attrs = val.force(vm)?.to_attrs()?; - let get = |key| { - attrs - .select(key) - .ok_or(ErrorKind::AttributeNotFound { name: key.into() }) - }; - let name = get("name")?.to_str()?; - let value = get("value")?.clone(); + let name = attrs.select_required("name")?.force(vm)?.to_str()?; + let value = attrs.select_required("value")?.clone(); // Map entries earlier in the list take precedence over entries later in the list map.entry(name).or_insert(value); } -- cgit 1.4.1