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:
parent
9a783e50a4
commit
786e12a738
3 changed files with 14 additions and 0 deletions
|
@ -1256,6 +1256,12 @@ pub fn compile(
|
||||||
|
|
||||||
c.compile(None, expr);
|
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 {
|
Ok(CompilationOutput {
|
||||||
lambda: c.contexts.pop().unwrap().lambda,
|
lambda: c.contexts.pop().unwrap().lambda,
|
||||||
warnings: c.warnings,
|
warnings: c.warnings,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
42
|
|
@ -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
|
Loading…
Reference in a new issue