diff options
author | Vincent Ambo <mail@tazj.in> | 2022-09-01T16·57+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-07T20·04+0000 |
commit | 55d21a1389504d6d9872144077196bac9ee17feb (patch) | |
tree | 25e8a57afc217102e6dd7a75b4d3eed33403e961 /tvix/eval/src/eval.rs | |
parent | 80333009008b8a6ee644b7504b65f4c337418a3b (diff) |
refactor(tvix/eval): store spans instead of nodes in Warning/Error r/4737
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 <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/eval.rs')
-rw-r--r-- | tvix/eval/src/eval.rs | 11 |
1 files changed, 6 insertions, 5 deletions
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<PathBuf>) -> EvalResult<Value> { 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 ); } |