Skip to content

Commit

Permalink
Avoid issuing an extra error
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Jul 17, 2024
1 parent 510d16c commit 79611dc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions compiler/noirc_frontend/src/elaborator/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,22 +750,23 @@ impl<'context> Elaborator<'context> {
&mut self,
func: ExprId,
location: Location,
) -> Result<FuncId, ResolverError> {
) -> Result<Option<FuncId>, ResolverError> {
match self.interner.expression(&func) {
HirExpression::Ident(ident, _generics) => {
if let Some(definition) = self.interner.try_definition(ident.id) {
if let DefinitionKind::Function(function) = definition.kind {
let meta = self.interner.function_modifiers(&function);
if meta.is_comptime {
Ok(function)
Ok(Some(function))
} else {
Err(ResolverError::MacroIsNotComptime { span: location.span })
}
} else {
Err(ResolverError::InvalidSyntaxInMacroCall { span: location.span })
}
} else {
Err(ResolverError::InvalidSyntaxInMacroCall { span: location.span })
// Assume a name resolution error has already been issued
Ok(None)
}
}
_ => Err(ResolverError::InvalidSyntaxInMacroCall { span: location.span }),
Expand All @@ -786,7 +787,7 @@ impl<'context> Elaborator<'context> {
});

let function = match self.try_get_comptime_function(func, location) {
Ok(function) => function,
Ok(function) => function?,
Err(error) => {
self.push_err(error);
return None;
Expand Down

0 comments on commit 79611dc

Please sign in to comment.