diff options
author | Vincent Ambo <mail@tazj.in> | 2022-09-04T22·35+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-10T21·57+0000 |
commit | 4e06e5d2baf99de503decfb3cc92240baf455ee4 (patch) | |
tree | 565eeafbfb963bc363d713ad0834c4545e2e8fc4 /tvix/eval/src | |
parent | 06909f182151cf2332a14909e8b772ab4648854e (diff) |
fix(tvix/eval): reintroduce 'InvalidAttribuetName' error variant r/4787
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>
Diffstat (limited to 'tvix/eval/src')
-rw-r--r-- | tvix/eval/src/errors.rs | 6 | ||||
-rw-r--r-- | tvix/eval/src/value/attrs.rs | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index 2b8ba8f9631f..ad4acd479e05 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -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, }, diff --git a/tvix/eval/src/value/attrs.rs b/tvix/eval/src/value/attrs.rs index fddf0b582ccb..b8ae51bf48fc 100644 --- a/tvix/eval/src/value/attrs.rs +++ b/tvix/eval/src/value/attrs.rs @@ -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(), + }) + } } } |