fix(tvix/eval): force condition of an assert
Change-Id: I3ad2234e8a8e4280e498c6d7af8ea0733ed4c7ea Reviewed-on: https://cl.tvl.fyi/c/depot/+/6699 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
e04ccc9354
commit
7506983ce2
3 changed files with 9 additions and 0 deletions
|
@ -471,6 +471,7 @@ impl Compiler<'_> {
|
|||
fn compile_assert(&mut self, slot: LocalIdx, node: ast::Assert) {
|
||||
// Compile the assertion condition to leave its value on the stack.
|
||||
self.compile(slot, node.condition().unwrap());
|
||||
self.emit_force(&node.condition().unwrap());
|
||||
self.push_op(OpCode::OpAssert, &node.condition().unwrap());
|
||||
|
||||
// The runtime will abort evaluation at this point if the
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
21
|
|
@ -0,0 +1,7 @@
|
|||
let
|
||||
condition = x: y: x < y;
|
||||
in
|
||||
|
||||
# The function application here will become a thunk which verifies that
|
||||
# assert forces the condition expression correctly.
|
||||
assert condition 21 42; 21
|
Loading…
Reference in a new issue