about summary refs log tree commit diff
path: root/tvix/eval/src/vm/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/vm/mod.rs')
-rw-r--r--tvix/eval/src/vm/mod.rs30
1 files changed, 19 insertions, 11 deletions
diff --git a/tvix/eval/src/vm/mod.rs b/tvix/eval/src/vm/mod.rs
index d57bd21e44c7..44a29ba86f9d 100644
--- a/tvix/eval/src/vm/mod.rs
+++ b/tvix/eval/src/vm/mod.rs
@@ -538,19 +538,27 @@ impl<'o> VM<'o> {
                 }
 
                 OpCode::OpAttrsSelect => {
-                    let key = self.stack_pop().to_str().with_span(&frame, self)?;
-                    let attrs = self.stack_pop().to_attrs().with_span(&frame, self)?;
+                    let key = self.stack_pop();
+                    let attrs = self.stack_pop();
+                    if key.is_catchable() {
+                        self.stack.push(key);
+                    } else if attrs.is_catchable() {
+                        self.stack.push(attrs);
+                    } else {
+                        let key = key.to_str().with_span(&frame, self)?;
+                        let attrs = attrs.to_attrs().with_span(&frame, self)?;
 
-                    match attrs.select(key.as_str()) {
-                        Some(value) => self.stack.push(value.clone()),
+                        match attrs.select(key.as_str()) {
+                            Some(value) => self.stack.push(value.clone()),
 
-                        None => {
-                            return frame.error(
-                                self,
-                                ErrorKind::AttributeNotFound {
-                                    name: key.as_str().to_string(),
-                                },
-                            );
+                            None => {
+                                return frame.error(
+                                    self,
+                                    ErrorKind::AttributeNotFound {
+                                        name: key.as_str().to_string(),
+                                    },
+                                );
+                            }
                         }
                     }
                 }