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:
parent
f95b23d743
commit
240d90aa8a
3 changed files with 12 additions and 1 deletions
|
@ -168,7 +168,9 @@ impl Compiler<'_, '_> {
|
||||||
c.compile_select(s, sel.clone())
|
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::IfElse(if_else) => self.compile_if_else(slot, if_else),
|
||||||
ast::Expr::LetIn(let_in) => self.compile_let_in(slot, let_in),
|
ast::Expr::LetIn(let_in) => self.compile_let_in(slot, let_in),
|
||||||
ast::Expr::Ident(ident) => self.compile_ident(slot, ident),
|
ast::Expr::Ident(ident) => self.compile_ident(slot, ident),
|
||||||
|
|
1
tvix/eval/src/tests/tvix_tests/eval-okay-lazy-assert.exp
Normal file
1
tvix/eval/src/tests/tvix_tests/eval-okay-lazy-assert.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
12
|
8
tvix/eval/src/tests/tvix_tests/eval-okay-lazy-assert.nix
Normal file
8
tvix/eval/src/tests/tvix_tests/eval-okay-lazy-assert.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
assert true;
|
||||||
|
|
||||||
|
let
|
||||||
|
x = assert false; 13;
|
||||||
|
y = 12;
|
||||||
|
in
|
||||||
|
|
||||||
|
{ inherit x y; }.y
|
Loading…
Reference in a new issue