about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-09T15·19+0300
committertazjin <tazjin@tvl.su>2022-08-13T20·24+0000
commite876c3a41c89bfc9d40ee64a4f12fb70d5357a87 (patch)
treeced8e4f1573a82ec286e0c38df166efd109c6a01 /tvix
parent2dcbbb8c4a737483fcd2133411ef425299a741fd (diff)
fix(tvix/value): KV struct needs to carry name as Value, too r/4437
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 <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/value/attrs.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs
index 1658d69c7ee7..e2ebc7cb344a 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<NixString, Value>),
-    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) => {