fix: subtyping bug

This commit is contained in:
Shunsuke Shibayama 2023-06-10 11:16:30 +09:00
parent 57e5a50e1b
commit 0840d9bf60
11 changed files with 120 additions and 81 deletions

View file

@ -209,9 +209,13 @@ impl TyVarCache {
pub(crate) fn get_tyvar(&self, name: &str) -> Option<&Type> {
self.tyvar_instances.get(name).or_else(|| {
self.typaram_instances
.get(name)
.map(|tp| <&Type>::try_from(tp).unwrap())
self.typaram_instances.get(name).and_then(|tp| {
<&Type>::try_from(tp)
.map_err(|_| {
log!(err "cannot convert {tp} into a type");
})
.ok()
})
})
}