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 <grfn@gws.fyi>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-16 15:53:35 +03:00 committed by tazjin
parent 8fa3bc7137
commit a00e4730a5
4 changed files with 27 additions and 0 deletions

View file

@ -304,6 +304,12 @@ impl VM {
return Err(Error::UnknownDynamicVariable(ident.to_string()));
}
OpCode::OpAssert => {
if !self.pop().as_bool()? {
return Err(Error::AssertionFailed);
}
}
}
#[cfg(feature = "disassembler")]