Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow ast when macro errors #4005

Merged
merged 11 commits into from
Jan 12, 2024
9 changes: 5 additions & 4 deletions compiler/noirc_frontend/src/hir/def_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,15 @@ impl CrateDefMap {
let mut ast = ast.into_sorted();

for macro_processor in &macro_processors {
ast = match macro_processor.process_untyped_ast(ast, &crate_id, context) {
Ok(ast) => ast,
match macro_processor.process_untyped_ast(ast.clone(), &crate_id, context) {
Ok(processed_ast) => {
ast = processed_ast;
}
Err((error, file_id)) => {
let def_error = DefCollectorErrorKind::MacroError(error);
errors.push((def_error.into(), file_id));
return errors;
}
};
}
}

// Allocate a default Module for the root, giving it a ModuleId
Expand Down
3 changes: 2 additions & 1 deletion compiler/noirc_frontend/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ fn force<'a, T: 'a>(parser: impl NoirParser<T> + 'a) -> impl NoirParser<Option<T
parser.map(Some).recover_via(empty().map(|_| None))
}

#[derive(Default)]
#[derive(Clone, Default)]
pub struct SortedModule {
pub imports: Vec<ImportStatement>,
pub functions: Vec<NoirFunction>,
Expand Down Expand Up @@ -344,6 +344,7 @@ impl std::fmt::Display for SortedSubModule {
}
}

#[derive(Clone)]
pub struct SortedSubModule {
pub name: Ident,
pub contents: SortedModule,
Expand Down
Loading