about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/compiler/mod.rs')
-rw-r--r--tvix/eval/src/compiler/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 01e07304bc3f..4edb5f204533 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -864,6 +864,10 @@ impl Compiler<'_> {
         self.compile(slot, node.condition().unwrap());
         self.emit_force(&node.condition().unwrap());
 
+        let throw_idx = self.push_op(
+            OpCode::OpJumpIfCatchable(JumpOffset(0)),
+            &node.condition().unwrap(),
+        );
         let then_idx = self.push_op(
             OpCode::OpJumpIfFalse(JumpOffset(0)),
             &node.condition().unwrap(),
@@ -879,6 +883,7 @@ impl Compiler<'_> {
         self.compile(slot, node.else_body().unwrap());
 
         self.patch_jump(else_idx); // patch jump *over* else body
+        self.patch_jump(throw_idx); // patch jump *over* else body
     }
 
     /// Compile `with` expressions by emitting instructions that
@@ -1328,6 +1333,7 @@ impl Compiler<'_> {
             OpCode::OpJump(n)
             | OpCode::OpJumpIfFalse(n)
             | OpCode::OpJumpIfTrue(n)
+            | OpCode::OpJumpIfCatchable(n)
             | OpCode::OpJumpIfNotFound(n)
             | OpCode::OpJumpIfNoFinaliseRequest(n) => {
                 *n = offset;