From 5ee89bcf5ca3f0b0d3b809b01ac04bf38f51d7e4 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 2 Sep 2022 01:19:53 +0300 Subject: fix(tvix/eval): inherit scope poisoning data in nested contexts Scope poisoning must be inherited across lambda context boundaries, e.g. if an outer scope has a poisoned `null`, any lambdas defined on the same level must reference that poisoned identifier correctly. Change-Id: I1aac64e1c048a6f3bacadb6d78ed295fa439e8b4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6410 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/compiler/scope.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tvix/eval/src/compiler/scope.rs') diff --git a/tvix/eval/src/compiler/scope.rs b/tvix/eval/src/compiler/scope.rs index b1ad4bfcd2b7..a50b3b79343e 100644 --- a/tvix/eval/src/compiler/scope.rs +++ b/tvix/eval/src/compiler/scope.rs @@ -152,6 +152,15 @@ impl Scope { } } + /// Inherit scope details from a parent scope (required for + /// correctly nesting scopes in lambdas and thunks when special + /// scope features like poisoning are present). + pub fn inherit(&self) -> Self { + let mut scope = Self::default(); + scope.poisoned_tokens = self.poisoned_tokens.clone(); + scope + } + /// Check whether a given token is poisoned. pub fn is_poisoned(&self, name: &str) -> bool { self.poisoned_tokens.contains_key(name) -- cgit 1.4.1