fix(tvix/eval): Thunk if expr

Since the body of an `if` expr can refer to deferred upvalues, it needs
to be thunked so when we actually compile those deferred upvalues we
have something for the finalize op to point at. Without this all sorts
of weird things can happen due to the finalize op being run in the wrong
lambda context, up to and including a panic.

Change-Id: I040d5e1a7232fd841cfa4953539898fa49cbbb83
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6929
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2022-10-10 15:57:54 -04:00 committed by clbot
parent 4fd18cbc9a
commit 2592113435
3 changed files with 10 additions and 1 deletions

View file

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

View file

@ -0,0 +1 @@
{ }

View file

@ -0,0 +1,6 @@
let
a = {};
in let
c = if builtins.isFunction a then a b else a;
b = {};
in c