From 33cde1422e473770ab0ca30759ece618cb4c3680 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 27 Aug 2022 03:31:28 +0300 Subject: feat(tvix/eval): implement upvalue resolution in `with` scopes These need to be handled specially by the runtime if the compiler determines that a given local must be resolved via `with`. Note that this implementation has a bug: It currently allows `with` inside of nested lambdas to shadow statically known identifiers. This will be cleaned up in the next commit. Change-Id: If196b99cbd1a0f2dbb4a40a0e88cdb09a009c6b9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6299 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.exp | 1 + tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.nix | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.exp new file mode 100644 index 000000000000..fa8f08cb6ff8 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.exp @@ -0,0 +1 @@ +150 diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.nix new file mode 100644 index 000000000000..7e2f7c073bfc --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-with-closure.nix @@ -0,0 +1,5 @@ +# Upvalues from `with` require special runtime handling. Do they work? +let + f = with { a = 15; }; n: n * a; +in +f 10 -- cgit 1.4.1