From 4fd18cbc9a756ea51dd04fa7bde9cfc79f4f8fa3 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 10 Oct 2022 11:54:53 -0400 Subject: feat(tvix/eval): Implement builtins.tryEval With asserts compiled using conditional jumps, this ends up being quite straightforward - the only real tricky bit is that we have to know whether an error can or can't be handled. Change-Id: I75617da73b7a9c5cdd888c0e26ae81d2c5c0d714 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6924 Reviewed-by: sterni Autosubmit: grfn Tested-by: BuildkiteCI --- tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp | 1 + tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp create mode 100644 tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix (limited to 'tvix/eval/src/tests/tvix_tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp new file mode 100644 index 000000000000..2b2e6fa711f4 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.exp @@ -0,0 +1 @@ +{ x = { success = true; value = "x"; }; y = { success = false; value = false; }; z = { success = false; value = false; }; } diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix new file mode 100644 index 000000000000..629bc440a85a --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-tryeval.nix @@ -0,0 +1,5 @@ +{ + x = builtins.tryEval "x"; + y = builtins.tryEval (assert false; "y"); + z = builtins.tryEval (throw "bla"); +} -- cgit 1.4.1