about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/eval/src/errors.rs6
-rw-r--r--tvix/eval/src/value/attrs.rs6
2 files changed, 11 insertions, 1 deletions
diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs
index 2b8ba8f963..ad4acd479e 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 fddf0b582c..b8ae51bf48 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(),
+                    })
+                }
             }
         }