From 240d90aa8a1ee9d9ac827fe19ea42d086be787d7 Mon Sep 17 00:00:00 2001 From: sterni Date: Wed, 7 Sep 2022 17:11:40 +0200 Subject: 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 Reviewed-by: sterni --- tvix/eval/src/compiler/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/compiler') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index c64492d54632..7cca7004abde 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -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), -- cgit 1.4.1