fix(tvix/eval): fix nested assertions b/340

This commit fixes our handling of `throw` within an `assert`
condition.

Fixes: b/340
Change-Id: I40a383639ec266da50a853f16216b1b7868495da
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10318
Autosubmit: Adam Joseph <adam@westernsemico.com>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Adam Joseph 2023-12-12 04:07:20 -08:00 committed by clbot
parent fc963033ae
commit 7b9eea71d0
3 changed files with 2 additions and 0 deletions

View file

@ -836,6 +836,7 @@ impl Compiler<'_> {
// Compile the assertion condition to leave its value on the stack.
self.compile(slot, node.condition().unwrap());
self.emit_force(&node.condition().unwrap());
let throw_idx = self.push_op(OpCode::OpJumpIfCatchable(JumpOffset(0)), node);
let then_idx = self.push_op(OpCode::OpJumpIfFalse(JumpOffset(0)), node);
self.push_op(OpCode::OpPop, node);
@ -848,6 +849,7 @@ impl Compiler<'_> {
self.push_op(OpCode::OpAssertFail, &node.condition().unwrap());
self.patch_jump(else_idx);
self.patch_jump(throw_idx);
}
/// Compile conditional expressions using jumping instructions in the VM.