summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevyn Cairns <devyn.cairns@gmail.com>2024-07-14 01:12:55 -0700
committerGitHub <noreply@github.com>2024-07-14 10:12:55 +0200
commitae40d56fc59565588ec1f004f70e5445cf54c727 (patch)
tree4f279c6198956de14eb9446cd0f85842e2aa6420
parentc5aa15c7f6b3e44b6c211d5e83617ced33424aec (diff)
Report parse warns and compile errs when running script files (#13369)
# Description Report parse warnings and compile errors when running script files. It's useful to report this information to script authors and users so they can know if they need to update something in the near future. I also found that moving some errors from eval to compile time meant some error tests can fail (in `tests/repl`) so this is a good idea to keep those passing. # User-Facing Changes - Report parse warnings when running script files - Report compile errors when running script files
-rw-r--r--crates/nu-cli/src/eval_file.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/nu-cli/src/eval_file.rs b/crates/nu-cli/src/eval_file.rs
index ff6ba36fe..bac4378d1 100644
--- a/crates/nu-cli/src/eval_file.rs
+++ b/crates/nu-cli/src/eval_file.rs
@@ -76,12 +76,21 @@ pub fn evaluate_file(
trace!("parsing file: {}", file_path_str);
let block = parse(&mut working_set, Some(file_path_str), &file, false);
+ if let Some(warning) = working_set.parse_warnings.first() {
+ report_error(&working_set, warning);
+ }
+
// If any parse errors were found, report the first error and exit.
if let Some(err) = working_set.parse_errors.first() {
report_error(&working_set, err);
std::process::exit(1);
}
+ if let Some(err) = working_set.compile_errors.first() {
+ report_error(&working_set, err);
+ // Not a fatal error, for now
+ }
+
// Look for blocks whose name starts with "main" and replace it with the filename.
for block in working_set.delta.blocks.iter_mut().map(Arc::make_mut) {
if block.signature.name == "main" {