Skip to content

Commit

Permalink
chore(semantic): print errors from examples/simple.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Aug 23, 2024
1 parent 4c88997 commit 7cc2bbd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions crates/oxc_semantic/examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ 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(());
}

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
Expand All @@ -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}",);
}

Expand Down

0 comments on commit 7cc2bbd

Please sign in to comment.