about summary refs log tree commit diff
path: root/tvix/eval/src/opcode.rs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2022-10-10T16·56-0400
committergrfn <grfn@gws.fyi>2022-10-10T17·51+0000
commit899fbdbddb93050f26236ff7c72e7ae4704d497b (patch)
tree08b0d09bb3da81e1132ce6b6f0dd065cde04a651 /tvix/eval/src/opcode.rs
parent1ab252470ac7baf29ac891e4e1ca1fc08a8968e5 (diff)
refactor(tvix/eval): Compile OpAssert using conditional jumps r/5082
In order to behave nicely with tryEval, asserts need to leave the
instruction pointer in a reasonable place even if they fail - whereas
with the previous implementation catching a failed assert would still
end up running the op for the *body* of the assert. With this change, we
compile asserts much more like an `if` expression with conditional jumps
rather than having an OpAssert op.

Change-Id: I1b266c3be90185c84000da6b1995ac3e6fd5471b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6925
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/opcode.rs')
-rw-r--r--tvix/eval/src/opcode.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tvix/eval/src/opcode.rs b/tvix/eval/src/opcode.rs
index c2eabba1c28e..15f60a538c41 100644
--- a/tvix/eval/src/opcode.rs
+++ b/tvix/eval/src/opcode.rs
@@ -121,8 +121,8 @@ pub enum OpCode {
     /// Close scopes while leaving their expression value around.
     OpCloseScope(Count), // number of locals to pop
 
-    /// Asserts stack top is a boolean, and true.
-    OpAssert,
+    /// Return an error indicating that an `assert` failed
+    OpAssertFail,
 
     // Lambdas & closures
     OpCall,