Skip to content

Commit

Permalink
Panic when encountering unknown generics.
Browse files Browse the repository at this point in the history
  This should not happen; if it does, it's an error from the type-checker. So instead of silently swallowing the error and adopting a behavior which is only _sometimes_ right, it is better to fail loudly and investigate.
  • Loading branch information
KtorZ authored and MicroProofs committed May 6, 2024
1 parent b2661ef commit 2ba640d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/aiken-lang/src/tipo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,9 +819,12 @@ pub fn find_and_replace_generics(
mono_types: &IndexMap<u64, Rc<Type>>,
) -> Rc<Type> {
if let Some(id) = tipo.get_generic() {
// If a generic does not have a type we know of
// like a None in option then just use same type
mono_types.get(&id).unwrap_or(tipo).clone()
mono_types
.get(&id)
.unwrap_or_else(|| {
panic!("Unknown generic id {id:?} for type {tipo:?} in mono_types {mono_types:#?}");
})
.clone()
} else if tipo.is_generic() {
match &**tipo {
Type::App {
Expand Down

0 comments on commit 2ba640d

Please sign in to comment.