From a00e4730a5ec824a8452152de72458230f72e61a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 16 Aug 2022 15:53:35 +0300 Subject: feat(tvix/eval): implement `assert` operator 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 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/opcode.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tvix/eval/src/opcode.rs') 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, } -- cgit 1.4.1