From 0f739cd94424c3cbad62bc69de72ee4fff2b6f58 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 16 Aug 2022 15:11:06 +0300 Subject: feat(tvix/eval): implement scope poisoning for true/false/null These tokens are optionally parsed as identifiers by Nix, which means that within any scopes that resolve them the compiler needs to track whether they have been overridden to know whether to emit the literal instructions or resolve a variable. This is implemented by a new concept of "scope poisoning", where the compiler's scope structure tracks whether or not any builtin identifiers have been overridden. Change-Id: I3ab711146e229f843f6e1f0343385382ee0aecb6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6227 Tested-by: BuildkiteCI Reviewed-by: sterni Reviewed-by: grfn --- tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.exp | 1 + tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.nix | 6 ++++++ tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.exp | 1 + tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.nix | 7 +++++++ 4 files changed, 15 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.nix create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.exp new file mode 100644 index 000000000000..5776134d0e41 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.exp @@ -0,0 +1 @@ +[ 1 2 3 ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.nix new file mode 100644 index 000000000000..81f03d9e2b09 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-poisoned-scopes.nix @@ -0,0 +1,6 @@ +let + true = 1; + false = 2; + null = 3; +in +[ true false null ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.exp new file mode 100644 index 000000000000..5462431496bc --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.exp @@ -0,0 +1 @@ +[ true false null 1 2 3 ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.nix new file mode 100644 index 000000000000..30e9667da821 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-unpoison-scope.nix @@ -0,0 +1,7 @@ +let + poisoned = let + true = 1; + false = 2; + null = 3; + in [ true false null ]; +in [ true false null ] ++ poisoned -- cgit 1.4.1