Skip to content

Commit

Permalink
fix: Run macro processors in the elaborator (#5472)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

Applies the macro processors when we're using the elaborator too.

## Additional Context

I wasn't able to test this well since running `nargo t` in `aztec-nr`
produces quite a few errors regardless of whether we're using the
elaborator or legacy code.

## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
jfecher authored Jul 11, 2024
1 parent e0d7833 commit 89642c2
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,13 @@ impl DefCollector {
}
}

let handle_missing_file = |err| {
errors.push((CompilationError::DebugComptimeScopeNotFound(err), root_file_id));
None
};
let debug_comptime_in_file: Option<FileId> =
debug_comptime_in_file.and_then(|debug_comptime_in_file| {
context
.file_manager
.find_by_path_suffix(debug_comptime_in_file)
.unwrap_or_else(handle_missing_file)
});
let debug_comptime_in_file = debug_comptime_in_file.and_then(|debug_comptime_in_file| {
let file = context.file_manager.find_by_path_suffix(debug_comptime_in_file);
file.unwrap_or_else(|error| {
errors.push((CompilationError::DebugComptimeScopeNotFound(error), root_file_id));
None
})
});

if !use_legacy {
let mut more_errors = Elaborator::elaborate(
Expand All @@ -434,6 +430,14 @@ impl DefCollector {
debug_comptime_in_file,
);
errors.append(&mut more_errors);

for macro_processor in macro_processors {
macro_processor.process_typed_ast(&crate_id, context).unwrap_or_else(
|(macro_err, file_id)| {
errors.push((macro_err.into(), file_id));
},
);
}
return errors;
}

Expand Down

0 comments on commit 89642c2

Please sign in to comment.