feat(tvix/eval): always emit OpForce as the last instruction

Change-Id: Id70c987f654dc5d9b47db74e395281309762b468
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6353
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
This commit is contained in:
Vincent Ambo 2022-08-29 18:40:52 +03:00 committed by tazjin
parent 9a783e50a4
commit 786e12a738
3 changed files with 14 additions and 0 deletions

View file

@ -1256,6 +1256,12 @@ pub fn compile(
c.compile(None, expr);
// The final operation of any top-level Nix program must always be
// `OpForce`. A thunk should not be returned to the user in an
// unevaluated state (though in practice, a value *containing* a
// thunk might be returned).
c.chunk().push_op(OpCode::OpForce);
Ok(CompilationOutput {
lambda: c.contexts.pop().unwrap().lambda,
warnings: c.warnings,

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1,7 @@
# If a thunk yields another thunk, OpForce should keep forcing until
# there is a value.
let
a = b;
b = c;
c = 42;
in a