Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/noirc_frontend/src/monomorphization/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ use crate::hir::comptime::InterpreterError;
pub enum MonomorphizationError {
UnknownArrayLength { location: Location },
TypeAnnotationsNeeded { location: Location },
InternalError { message: &'static str, location: Location },
InterpreterError(InterpreterError),
}

impl MonomorphizationError {
fn location(&self) -> Location {
match self {
MonomorphizationError::UnknownArrayLength { location }
| MonomorphizationError::InternalError { location, .. }
| MonomorphizationError::TypeAnnotationsNeeded { location } => *location,
MonomorphizationError::InterpreterError(error) => error.get_location(),
}
Expand All @@ -36,6 +38,7 @@ impl MonomorphizationError {
}
MonomorphizationError::TypeAnnotationsNeeded { .. } => "Type annotations needed",
MonomorphizationError::InterpreterError(error) => return (&error).into(),
MonomorphizationError::InternalError { message, .. } => message,
};

let location = self.location();
Expand Down
6 changes: 5 additions & 1 deletion compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,11 @@ impl<'interner> Monomorphizer<'interner> {
DefinitionKind::Local(_) => match self.lookup_captured_expr(ident.id) {
Some(expr) => expr,
None => {
let ident = self.local_ident(&ident)?.unwrap();
let Some(ident) = self.local_ident(&ident)? else {
let location = self.interner.id_location(expr_id);
let message = "ICE: Variable not found during monomorphization";
return Err(MonomorphizationError::InternalError { location, message });
};
ast::Expression::Ident(ident)
}
},
Expand Down