about summary refs log tree commit diff
path: root/tvix/eval/src/opcode.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-16T12·53+0300
committertazjin <tazjin@tvl.su>2022-09-01T17·41+0000
commita00e4730a5ec824a8452152de72458230f72e61a (patch)
tree24ebc2c3839bb707abbb19f1efb17f8d59dae847 /tvix/eval/src/opcode.rs
parent8fa3bc71374eba92c79346c1d0e92d9445b87a71 (diff)
feat(tvix/eval): implement `assert` operator r/4566
This implements `assert`, which evaluates an expression and aborts
evaluation if the value is not `true`.

At this point we should introduce eval-failed-* tests; probably
asserting against some representation of the error enum?

Change-Id: If54c8f616d89b829c1860a4835dde60a2cd70d7a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6230
Reviewed-by: grfn <grfn@gws.fyi>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/opcode.rs')
-rw-r--r--tvix/eval/src/opcode.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/tvix/eval/src/opcode.rs b/tvix/eval/src/opcode.rs
index 7dcfea93aaf7..cda3fdf26be5 100644
--- a/tvix/eval/src/opcode.rs
+++ b/tvix/eval/src/opcode.rs
@@ -72,4 +72,7 @@ pub enum OpCode {
 
     // Close scopes while leaving their expression value around.
     OpCloseScope(usize), // number of locals to pop
+
+    // Asserts stack top is a boolean, and true.
+    OpAssert,
 }