Panic when encountering unknown generics.
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.
This commit is contained in:
parent
b2661ef90a
commit
1070347203
|
@ -819,9 +819,12 @@ pub fn find_and_replace_generics(
|
||||||
mono_types: &IndexMap<u64, Rc<Type>>,
|
mono_types: &IndexMap<u64, Rc<Type>>,
|
||||||
) -> Rc<Type> {
|
) -> Rc<Type> {
|
||||||
if let Some(id) = tipo.get_generic() {
|
if let Some(id) = tipo.get_generic() {
|
||||||
// If a generic does not have a type we know of
|
mono_types
|
||||||
// like a None in option then just use same type
|
.get(&id)
|
||||||
mono_types.get(&id).unwrap_or(tipo).clone()
|
.unwrap_or_else(|| {
|
||||||
|
panic!("Unknown generic id {id:?} for type {tipo:?} in mono_types {mono_types:#?}");
|
||||||
|
})
|
||||||
|
.clone()
|
||||||
} else if tipo.is_generic() {
|
} else if tipo.is_generic() {
|
||||||
match &**tipo {
|
match &**tipo {
|
||||||
Type::App {
|
Type::App {
|
||||||
|
|
Loading…
Reference in New Issue