From ac3d717944412b17d7dcd18006c2f9f522b1b3f7 Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Thu, 4 Jul 2024 23:39:51 -0400 Subject: feat(tvix/eval): Allow passing in an env to evaluation Allow passing in a top-level env, a map from name to value, to evaluation. The intent is to support bound identifiers in the REPL just like upstream nix does. Getting this working involves mucking around a bit with internals - most notably, locals now only optionally have a Span (since locals don't have an easy span we can use) - and getting that working requires propagating some minor hacks to places where we currently *need* a span (and which would require too much changing now to make spans optional; my guess is that that would essentially end up making spans optional throughout the codebase). Also, some extra care has to be taken to close out the scope in the case that we do pass in an env, to avoid breaking our assumptions about the size of the stack when we return from the toplevel Change-Id: Ie475b2d3dfc72ccbf298d2a3ea28c63ac877d653 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11953 Tested-by: BuildkiteCI Autosubmit: aspen Reviewed-by: flokli --- tvix/eval/src/errors.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tvix/eval/src/errors.rs') diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index e32cfa04ed40..ee55552c7ac5 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -109,7 +109,7 @@ pub enum ErrorKind { UnknownDynamicVariable(String), /// User is defining the same variable twice at the same depth. - VariableAlreadyDefined(Span), + VariableAlreadyDefined(Option), /// Attempt to call something that is not callable. NotCallable(&'static str), -- cgit 1.4.1