fix(tvix/eval): wrap asserts in a thunk

As the new test case demonstrates, asserts need to be evaluated lazily.

Change-Id: I808046722c5a504e9497855ca5026d255c7a4c34
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6494
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
sterni 2022-09-07 17:11:40 +02:00 committed by tazjin
parent f95b23d743
commit 240d90aa8a
3 changed files with 12 additions and 1 deletions

View file

@ -168,7 +168,9 @@ impl Compiler<'_, '_> {
c.compile_select(s, sel.clone())
}),
ast::Expr::Assert(assert) => self.compile_assert(slot, assert),
ast::Expr::Assert(assert) => {
self.thunk(slot, &assert, move |c, a, s| c.compile_assert(s, a.clone()))
}
ast::Expr::IfElse(if_else) => self.compile_if_else(slot, if_else),
ast::Expr::LetIn(let_in) => self.compile_let_in(slot, let_in),
ast::Expr::Ident(ident) => self.compile_ident(slot, ident),

View file

@ -0,0 +1 @@
12

View file

@ -0,0 +1,8 @@
assert true;
let
x = assert false; 13;
y = 12;
in
{ inherit x y; }.y