From 55d21a1389504d6d9872144077196bac9ee17feb Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 1 Sep 2022 19:57:55 +0300 Subject: refactor(tvix/eval): store spans instead of nodes in Warning/Error Another step towards being able to report accurate errors. The codemap spans contain strictly more accessible information, as they now retain information about which input file something came from. This required some shuffling around in the compiler to thread all the right information to the right places. Change-Id: I18ccfb20f07b0c33e1c4f51ca00cd09f7b2d19c6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6404 Reviewed-by: sterni Tested-by: BuildkiteCI --- tvix/eval/src/eval.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tvix/eval/src/eval.rs') diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs index 98e7520e8b2e..c72e40c75d34 100644 --- a/tvix/eval/src/eval.rs +++ b/tvix/eval/src/eval.rs @@ -43,18 +43,19 @@ pub fn interpret(code: &str, location: Option) -> EvalResult { for warning in result.warnings { eprintln!( - "warning: {:?} at `{:?}`[{:?}]", + "warning: {:?} at `{}`[line {}]", warning.kind, - warning.node.text(), - warning.node.text_range().start() + file.source_slice(warning.span), + file.find_line(warning.span.low()) + 1 ) } for error in &result.errors { eprintln!( - "compiler error: {:?} at {:?}", + "compiler error: {:?} at `{}`[line {}]", error.kind, - error.node.as_ref().map(|node| node.text()) + file.source_slice(error.span.expect("TODO: non-optional")), + file.find_line(error.span.unwrap().low()) + 1 ); } -- cgit 1.4.1