about summary refs log tree commit diff
path: root/tvix/eval/src/vm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/vm.rs')
-rw-r--r--tvix/eval/src/vm.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tvix/eval/src/vm.rs b/tvix/eval/src/vm.rs
index ed040cf91743..3e8509187b4d 100644
--- a/tvix/eval/src/vm.rs
+++ b/tvix/eval/src/vm.rs
@@ -187,6 +187,20 @@ impl VM {
                         self.ip += offset;
                     }
                 }
+
+                // These assertion operations error out if the stack
+                // top is not of the expected type. This is necessary
+                // to implement some specific behaviours of Nix
+                // exactly.
+                OpCode::OpAssertBool => {
+                    let val = self.peek(0);
+                    if !val.is_bool() {
+                        return Err(Error::TypeError {
+                            expected: "bool",
+                            actual: val.type_of(),
+                        });
+                    }
+                }
             }
 
             if self.ip == self.chunk.code.len() {