fixed fmt error reporting

This commit is contained in:
Jakub Doka 2024-10-26 09:53:14 +02:00
parent 855da58e06
commit af4d965b8c
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
2 changed files with 6 additions and 6 deletions

View file

@ -81,6 +81,11 @@ pub fn run_compiler(root_file: &str, options: Options, out: &mut Vec<u8>) -> std
Ok(()) Ok(())
} }
if !options.optimize && !parsed.errors.is_empty() {
log::error!("{}", parsed.errors);
return Err(std::io::Error::other("parsing failed"));
}
if options.fmt { if options.fmt {
for parsed in parsed.ast { for parsed in parsed.ast {
format_ast(parsed)?; format_ast(parsed)?;
@ -109,11 +114,6 @@ pub fn run_compiler(root_file: &str, options: Options, out: &mut Vec<u8>) -> std
codegen.assemble(out); codegen.assemble(out);
} }
} else { } else {
if !parsed.errors.is_empty() {
log::error!("{}", parsed.errors);
return Err(std::io::Error::other("parsing failed"));
}
let mut codegen = codegen::Codegen::default(); let mut codegen = codegen::Codegen::default();
codegen.files = parsed.ast; codegen.files = parsed.ast;
codegen.push_embeds(parsed.embeds); codegen.push_embeds(parsed.embeds);

View file

@ -141,7 +141,7 @@ impl Nodes {
log::info!("{out}"); log::info!("{out}");
} }
fn graphviz_in_browser(&self, tys: &Types, files: &[parser::Ast]) { fn graphviz_in_browser(&self, _tys: &Types, _files: &[parser::Ast]) {
#[cfg(all(debug_assertions, feature = "std"))] #[cfg(all(debug_assertions, feature = "std"))]
{ {
// let out = &mut String::new(); // let out = &mut String::new();