From 063c03900319e72888c84ec288a3ec87386f64ab Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 13 Apr 2021 23:11:02 +0200 Subject: [PATCH] report parse errors in the plaform module --- compiler/load/src/file.rs | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index f61b9cc71a..1a91ae2837 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -1146,7 +1146,7 @@ impl<'a> LoadStart<'a> { let (root_id, root_msg) = { let root_start_time = SystemTime::now(); - load_filename( + let res_loaded = load_filename( arena, filename, true, @@ -1154,7 +1154,26 @@ impl<'a> LoadStart<'a> { Arc::clone(&arc_modules), Arc::clone(&ident_ids_by_module), root_start_time, - )? + ); + + match res_loaded { + Ok(good) => good, + + Err(LoadingProblem::ParsingFailed(problem)) => { + let module_ids = Arc::try_unwrap(arc_modules) + .unwrap_or_else(|_| { + panic!("There were still outstanding Arc references to module_ids") + }) + .into_inner() + .into_module_ids(); + + // if parsing failed, this module did not add any identifiers + let root_exposed_ident_ids = IdentIds::exposed_builtins(0); + let buf = to_parse_problem_report(problem, module_ids, root_exposed_ident_ids); + return Err(LoadingProblem::FormattedReport(buf)); + } + Err(e) => return Err(e), + } }; Ok(LoadStart { @@ -3224,7 +3243,7 @@ fn fabricate_pkg_config_module<'a>( app_module_id, packages: &[], provides, - requires: header.requires.clone().into_bump_slice(), + requires: arena.alloc([header.requires.signature.clone()]), imports: header.imports.clone().into_bump_slice(), };