about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/errors.rs4
-rw-r--r--tvix/eval/src/vm.rs6
2 files changed, 9 insertions, 1 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index 118c10621551..8a85972923c5 100644
--- a/tvix/eval/src/errors.rs
+++ b/tvix/eval/src/errors.rs
@@ -2,6 +2,10 @@ use std::fmt::Display;
 
 #[derive(Debug)]
 pub enum Error {
+    DuplicateAttrsKey {
+        key: String,
+    },
+
     TypeError {
         expected: &'static str,
         actual: &'static str,
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index 58ef67cb5531..0c8ea4ffd1f6 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -211,8 +211,12 @@ impl VM {
         for _ in 0..count {
             let value = self.pop();
             let key = self.pop().as_string()?; // TODO(tazjin): attrpath
-            attrs.insert(key, value);
+
+            if attrs.insert(key.clone(), value).is_some() {
+                return Err(Error::DuplicateAttrsKey { key: key.0 });
+            }
         }
+
         // TODO(tazjin): extend_reserve(count) (rust#72631)
 
         self.push(Value::Attrs(Rc::new(NixAttrs::Map(attrs))));