fix(tvix/eval): ensure that root stack slot actually exists

Instead of using a sentinel LocalIdx which potentially points to a
value in the locals stack that does not actually exist, set up an
initial uninitialised phantom value representing the result of the
root expression.

Change-Id: I82ea774daab83168020a3850bed57d35ab25c7df
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6424
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-09-03 03:09:18 +03:00 committed by tazjin
parent f8575fcd74
commit ecbd7c6ca1
2 changed files with 3 additions and 5 deletions

View file

@ -1382,7 +1382,9 @@ pub fn compile<'code>(
c.context_mut().lambda.chunk.codemap = c.codemap.clone();
}
c.compile(LocalIdx::ZERO, expr.clone());
let root_span = c.span_for(&expr);
let root_slot = c.scope_mut().declare_phantom(root_span);
c.compile(root_slot, expr.clone());
// The final operation of any top-level Nix program must always be
// `OpForce`. A thunk should not be returned to the user in an