Skip to content

Commit

Permalink
fix: Don't lazily elaborate functions (#5282)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #5271

## Summary\*

Lazily elaborating functions wasn't correct since the FuncMeta object
never stored the LocalModuleId carried by the set of unresolved
functions. This lead to lazily elaborated functions be elaborated in a
different module than intended.

## Additional Context

Lazily elaborated functions seem to no longer be necessary to run our
tests, nor to run the tests in aztec-nr so I've just removed them rather
than adding the additional fields to FuncMeta.

## 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 Jun 19, 2024
1 parent 19884f1 commit 0ea608f
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions compiler/noirc_frontend/src/elaborator/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ use crate::{
},
hir_def::{
expr::{HirIdent, ImplKind},
function::FunctionBody,
stmt::HirPattern,
},
macros_api::{HirExpression, Ident, Path, Pattern},
node_interner::{DefinitionId, DefinitionKind, DependencyId, ExprId, GlobalId, TraitImplKind},
node_interner::{DefinitionId, DefinitionKind, ExprId, GlobalId, TraitImplKind},
Shared, StructType, Type, TypeBindings,
};

Expand Down Expand Up @@ -415,16 +414,6 @@ impl<'context> Elaborator<'context> {
match self.interner.definition(hir_ident.id).kind {
DefinitionKind::Function(id) => {
if let Some(current_item) = self.current_item {
// Lazily evaluate functions found within globals if necessary.
// Otherwise if we later attempt to evaluate the global it will
// see an empty function body.
if matches!(current_item, DependencyId::Global(_)) {
let meta = self.interner.function_meta(&id);

if matches!(&meta.function_body, FunctionBody::Unresolved(..)) {
self.elaborate_function(id);
}
}
self.interner.add_function_dependency(current_item, id);
}
}
Expand Down

0 comments on commit 0ea608f

Please sign in to comment.