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:
parent
175eb97505
commit
e15bd9aa63
2 changed files with 9 additions and 1 deletions
|
@ -2,6 +2,10 @@ use std::fmt::Display;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
DuplicateAttrsKey {
|
||||
key: String,
|
||||
},
|
||||
|
||||
TypeError {
|
||||
expected: &'static str,
|
||||
actual: &'static str,
|
||||
|
|
|
@ -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))));
|
||||
|
|
Loading…
Reference in a new issue