fix(tvix/eval): end scope after compiling legacy let bindings

When contrasting the compilation of the desugared version to the
"sugared" version, this was the noticeable difference.

This fixes b/203.

Change-Id: Iae02ffc56e06de1de091b84cdc59d8fe83a17d69
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6898
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-10-08 22:06:27 +03:00 committed by clbot
parent b4d978cd6a
commit 207f3dd47e
3 changed files with 7 additions and 0 deletions

View file

@ -659,6 +659,11 @@ impl Compiler<'_> {
self.emit_warning(node, WarningKind::DeprecatedLegacyLet); self.emit_warning(node, WarningKind::DeprecatedLegacyLet);
self.scope_mut().begin_scope(); self.scope_mut().begin_scope();
self.compile_bindings(slot, BindingsKind::RecAttrs, node); self.compile_bindings(slot, BindingsKind::RecAttrs, node);
// Remove the temporary scope, but do not emit any additional cleanup
// (OpAttrs consumes all of these locals).
self.scope_mut().end_scope();
self.emit_constant(Value::String(SmolStr::new_inline("body").into()), node); self.emit_constant(Value::String(SmolStr::new_inline("body").into()), node);
self.push_op(OpCode::OpAttrsSelect, node); self.push_op(OpCode::OpAttrsSelect, node);
} }

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1 @@
with {}; let { body = 42; }