From 8f2004d360dde108f90d2b49b0609bd43b7b6d7d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 21 Sep 2022 00:32:49 +0300 Subject: refactor(tvix/eval): add VM::call_value helper method This makes it possible to call a callable value (builtin or closure/lambda) directly, without unwrapping it first. This is needed for pretty much all higher-order functions to work correctly. This is mostly equivalent to the previous code in coerce_to_string for calling `__toString`, except it expects the argument(s) to already be placed on the stack. Note that the span for the `NotCallable` error is not currently guaranteed to make any sense, will experiment with this. Change-Id: I821224368d438a28900858b343defc1817e46a0a Reviewed-on: https://cl.tvl.fyi/c/depot/+/6717 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.exp | 2 +- tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.nix | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'tvix/eval/src/tests/tvix_tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.exp index e1ff708002..6cf5304032 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.exp +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.exp @@ -1 +1 @@ -[ [ 1 2 3 4 5 ] [ 2 4 6 8 10 ] [ 2 4 6 8 10 ] [ 1 2 3 4 5 ] ] +[ [ 1 2 3 4 5 ] [ 2 4 6 8 10 ] [ 2 4 6 8 10 ] [ 2 4 6 8 10 ] [ 1 2 3 4 5 ] ] diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.nix index 6ff42d0891..71b351fd55 100644 --- a/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.nix +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-builtins-map.nix @@ -11,6 +11,9 @@ in builtins.map (x: x * n) [ 1 2 3 4 5 ] ) + # same, but with a builtin + (builtins.map (builtins.mul 2) [ 1 2 3 4 5 ]) + # from global scope (map (x: x) [ 1 2 3 4 5 ]) ] -- cgit 1.4.1