From 8724d2fff871827dc66503f9b3dfa1d29149ddc7 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 21 Oct 2022 16:45:14 +0300 Subject: fix(tvix/eval): use top-level span for `force_with_output` When forcing thunks in `force_with_output`, the call stack of the VM is actually empty (as the calls are synthetic and no longer part of the evaluation of the top-level expression). This means that Tvix crashed when constructing error spans for the `fallible` macro, as the assumption of there being an enclosing span was violated. To work around this, we instead pass the span for the whole top-level expression to force_for_output and set this as the span for the enclosing error chain. Existing output logic will already avoid printing the entire expression as an error span. This fixes b/213. Change-Id: I93978e0deaf5bcb0f47a6fa95b3f5bebef5bad4c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7052 Autosubmit: tazjin Tested-by: BuildkiteCI Reviewed-by: grfn --- tvix/eval/src/tests/tvix_tests/eval-fail-builtins-thunk-error.nix | 1 + tvix/eval/src/tests/tvix_tests/eval-fail-deep-forced-thunk-error.nix | 1 + 2 files changed, 2 insertions(+) create mode 100644 tvix/eval/src/tests/tvix_tests/eval-fail-builtins-thunk-error.nix create mode 100644 tvix/eval/src/tests/tvix_tests/eval-fail-deep-forced-thunk-error.nix (limited to 'tvix/eval/src/tests') diff --git a/tvix/eval/src/tests/tvix_tests/eval-fail-builtins-thunk-error.nix b/tvix/eval/src/tests/tvix_tests/eval-fail-builtins-thunk-error.nix new file mode 100644 index 000000000000..bb0d5920d757 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-fail-builtins-thunk-error.nix @@ -0,0 +1 @@ +builtins.genList (_: {}.foo) 1 diff --git a/tvix/eval/src/tests/tvix_tests/eval-fail-deep-forced-thunk-error.nix b/tvix/eval/src/tests/tvix_tests/eval-fail-deep-forced-thunk-error.nix new file mode 100644 index 000000000000..b7a758302266 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-fail-deep-forced-thunk-error.nix @@ -0,0 +1 @@ +[ (throw "error!") ] -- cgit 1.4.1