From ae531a2245e83d44ce58ba6c588713265984dbbf Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 27 Aug 2022 22:58:39 +0300 Subject: feat(tvix/eval): implement capture of self-recursive upvalues With this change, it becomes possible for functions to call themselves as they are being defined in local bindings. Change-Id: Ib46a39ba17b1452b5673d96fa729d633d237241a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6314 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.exp | 1 + tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.nix | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.exp new file mode 100644 index 000000000000..be54b4b4e39e --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.exp @@ -0,0 +1 @@ +"done" diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.nix new file mode 100644 index 000000000000..bda364f42992 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-closure-self.nix @@ -0,0 +1,4 @@ +let + # self-recursive function should be able to close over itself + f = n: if n <= 0 then "done" else f (n - 1); +in f 10 -- cgit 1.4.1