From 7cc2bbd29308527df1c13021c43cdcc17a14f34a Mon Sep 17 00:00:00 2001 From: Boshen Date: Fri, 23 Aug 2024 22:57:26 +0800 Subject: [PATCH] chore(semantic): print errors from examples/simple.rs --- crates/oxc_semantic/examples/simple.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/oxc_semantic/examples/simple.rs b/crates/oxc_semantic/examples/simple.rs index eaed27b598366..74db9937446ca 100644 --- a/crates/oxc_semantic/examples/simple.rs +++ b/crates/oxc_semantic/examples/simple.rs @@ -26,9 +26,8 @@ fn main() -> std::io::Result<()> { let error_message: String = parser_ret .errors .into_iter() - .map(|error| error.with_source_code(Arc::clone(&source_text)).to_string()) - .join("\n\n"); - + .map(|error| format!("{:?}", error.with_source_code(Arc::clone(&source_text)))) + .join("\n"); println!("Parsing failed:\n\n{error_message}",); return Ok(()); } @@ -36,6 +35,7 @@ fn main() -> std::io::Result<()> { let program = allocator.alloc(parser_ret.program); let semantic = SemanticBuilder::new(&source_text, source_type) + .build_module_record(path.to_path_buf(), program) // Enable additional syntax checks not performed by the parser .with_check_syntax_error(true) // Inform Semantic about comments found while parsing @@ -46,9 +46,8 @@ fn main() -> std::io::Result<()> { let error_message: String = semantic .errors .into_iter() - .map(|error| error.with_source_code(Arc::clone(&source_text)).to_string()) - .join("\n\n"); - + .map(|error| format!("{:?}", error.with_source_code(Arc::clone(&source_text)))) + .join("\n"); println!("Semantic analysis failed:\n\n{error_message}",); }