fix(tvix/eval): Fail on duplicate attribute set keys

Change-Id: I57373ca76d0e25a5d08a8dfce9d5949099326fc0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6104
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2022-08-09 18:56:21 +03:00 committed by tazjin
parent 175eb97505
commit e15bd9aa63
2 changed files with 9 additions and 1 deletions

View file

@ -2,6 +2,10 @@ use std::fmt::Display;
#[derive(Debug)]
pub enum Error {
DuplicateAttrsKey {
key: String,
},
TypeError {
expected: &'static str,
actual: &'static str,

View file

@ -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))));