diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-29T19·28+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-07T15·25+0000 |
commit | a8b2ba07df0fb9f2fa19ce0f13c5fee9c0356599 (patch) | |
tree | d3c90dc2d2e9f7176e8c090bdf26fad3cb240173 /tvix/eval/src/compiler | |
parent | 17dfb92a9fb41fb785e9a53d19171200fd707081 (diff) |
fix(tvix/eval): correctly resolve identifiers in inherit r/4696
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 <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/compiler')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index 8a2fb5eb97e2..96c864110137 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); } } } |