From e876c3a41c89bfc9d40ee64a4f12fb70d5357a87 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 9 Aug 2022 18:19:34 +0300 Subject: fix(tvix/value): KV struct needs to carry name as Value, too Users may construct a pair that falls into the name/value optimisation but where `name` is not actually a string, as from the language perspective there is nothing special about this attribute set. We also can not conditionally apply this by forcing the key at this point, as this would change the language semantics. Therefore, the name in the optimised representation is also carried as `Value`. Change-Id: I5be8a4c98ba19ebdfb7203a929f714a04492512e Reviewed-on: https://cl.tvl.fyi/c/depot/+/6101 Reviewed-by: grfn Tested-by: BuildkiteCI --- tvix/eval/src/value/attrs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index 1658d69c7e..e2ebc7cb34 100644 --- a/tvix/eval/src/value/attrs.rs +++ b/tvix/eval/src/value/attrs.rs @@ -11,7 +11,7 @@ use super::Value; #[derive(Debug)] pub enum NixAttrs { Map(BTreeMap), - KV { name: NixString, value: Value }, + KV { name: Value, value: Value }, } impl Display for NixAttrs { @@ -22,6 +22,7 @@ impl Display for NixAttrs { NixAttrs::KV { name, value } => { f.write_fmt(format_args!("name = \"{}\"; ", name))?; f.write_fmt(format_args!("value = {}; ", value))?; + f.write_str("/* optimised pair! */")?; } NixAttrs::Map(map) => { -- cgit 1.4.1