From 786e12a7382eaaa957389b3a9e9e962efe7e8403 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 29 Aug 2022 18:40:52 +0300 Subject: 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 --- tvix/eval/src/compiler/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tvix/eval/src/compiler') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 2ae010ada6ed..e3cb15032a14 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -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, -- cgit 1.4.1