fix(tvix/eval): reintroduce 'InvalidAttribuetName' error variant

As pointed out by sterni in cl/6205, this is actually possible in
syntactically valid expressions like

  { ${12 + 13} = 12; }

Change-Id: Id8a1e3aceb551f288f9050c4eea563eb6572f1a7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6461
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-09-05 01:35:43 +03:00 committed by tazjin
parent 06909f1821
commit 4e06e5d2ba
2 changed files with 11 additions and 1 deletions

View file

@ -6,6 +6,12 @@ pub enum ErrorKind {
key: String,
},
/// Attempted to specify an invalid key type (e.g. integer) in a
/// dynamic attribute name.
InvalidAttributeName {
given: &'static str,
},
AttributeNotFound {
name: String,
},

View file

@ -286,7 +286,11 @@ impl NixAttrs {
continue;
}
other => panic!("unexpected attribute key: {} :: {}", other, other.type_of()),
other => {
return Err(ErrorKind::InvalidAttributeName {
given: other.type_of(),
})
}
}
}