From a8b2ba07df0fb9f2fa19ce0f13c5fee9c0356599 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 29 Aug 2022 22:28:13 +0300 Subject: fix(tvix/eval): correctly resolve identifiers in inherit This should not have grown a second implementation of the identifier resolution logic, but it somehow did. This implementation ended up being incorrect because it did not account for upvalues inside of thunks. Change-Id: Ieb1364d8fe43c96aaf4b125fd4b8a522aedff167 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6360 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/compiler/mod.rs | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'tvix') diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 8a2fb5eb97..96c8641101 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -442,29 +442,12 @@ impl Compiler { None => { for ident in inherit.idents() { count += 1; + + // Emit the key to use for OpAttrs self.emit_literal_ident(&ident); - match self - .scope_mut() - .resolve_local(ident.ident_token().unwrap().text()) - { - LocalPosition::Unknown => { - self.emit_error( - ident.syntax().clone(), - ErrorKind::UnknownStaticVariable, - ); - continue; - } - - LocalPosition::Known(idx) => { - let stack_idx = self.scope().stack_index(idx); - self.chunk().push_op(OpCode::OpGetLocal(stack_idx)) - } - - LocalPosition::Recursive(_) => { - todo!("TODO: should be unreachable in inherits, check") - } - }; + // Emit the value. + self.compile_ident(slot, ident); } } } -- cgit 1.4.1