Skip to main content

luaur_analysis/functions/
is_normalized_tyvar.rs

1use crate::functions::is_plain_tyvar::is_plain_tyvar;
2use crate::functions::is_shallow_inhabited::is_shallow_inhabited;
3use crate::functions::tyvar_index::tyvar_index;
4use crate::type_aliases::normalized_tyvars::NormalizedTyvars;
5
6pub fn is_normalized_tyvar(tyvars: &NormalizedTyvars) -> bool {
7    for (tyvar, intersect) in tyvars {
8        if !is_plain_tyvar(*tyvar) {
9            return false;
10        }
11        if !is_shallow_inhabited(intersect) {
12            return false;
13        }
14        for (other, _) in &intersect.tyvars {
15            if tyvar_index(*other) <= tyvar_index(*tyvar) {
16                return false;
17            }
18        }
19    }
20    true
21}