From 377ba19d75a0354c51d73dd38c4a29feefcc68e4 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 1 Sep 2022 23:50:27 +0300 Subject: feat(tvix/eval): ensure all errors always carry a span Previously error spans were optional because the information about code spans was not available at runtime. Now that this information has been added, the error type will always carry a span. This change is very invasive all throughout the codebase. This is due to the fact that many functions that are called *by* the VM expected to return `EvalResult`, but this no longer works as the span information is not available to those functions - only to the VM itself. To work around this the majority of these functions have been changed to return `Result` instead and an accompanying macro in the VM constructs the "real" error. Note that this implementatino currently has a bug where errors occuring within thunks will yield the location at which the thunk was forced, not the location at which the error occured within the code. This will be fixed soon, but the commit is large enough as is. Change-Id: Ib1ecb81a4d09d464a95ea7ea9e589f3bd08d5202 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6408 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/errors.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'tvix/eval/src/errors.rs') diff --git a/tvix/eval/src/errors.rs b/tvix/eval/src/errors.rs index aced6f6a55..59142f2efe 100644 --- a/tvix/eval/src/errors.rs +++ b/tvix/eval/src/errors.rs @@ -53,13 +53,7 @@ pub enum ErrorKind { #[derive(Clone, Debug)] pub struct Error { pub kind: ErrorKind, - pub span: Option, -} - -impl From for Error { - fn from(kind: ErrorKind) -> Self { - Error { span: None, kind } - } + pub span: codemap::Span, } impl Display for Error { -- cgit 1.4.1