fix: mutable container bug

This commit is contained in:
Shunsuke Shibayama 2023-10-03 00:00:37 +09:00
parent d5cbff6701
commit 73958a3e56
2 changed files with 45 additions and 0 deletions

View file

@ -526,6 +526,47 @@ impl<'c, 'l, 'u, L: Locational> Unifier<'c, 'l, 'u, L> {
Ok(())
}
}
(
TyParam::App {
name: ln,
args: largs,
},
TyParam::App {
name: rn,
args: rargs,
},
) if ln == rn => {
for (l, r) in largs.iter().zip(rargs.iter()) {
self.sub_unify_tp(l, r, _variance, allow_divergence)?;
}
Ok(())
}
(l, TyParam::Value(sup)) => {
let sup = match Context::convert_value_into_tp(sup.clone()) {
Ok(r) => r,
Err(tp) => {
return type_feature_error!(
self.ctx,
self.loc.loc(),
&format!("unifying {l} and {tp}")
)
}
};
self.sub_unify_tp(maybe_sub, &sup, _variance, allow_divergence)
}
(TyParam::Value(sub), r) => {
let sub = match Context::convert_value_into_tp(sub.clone()) {
Ok(l) => l,
Err(tp) => {
return type_feature_error!(
self.ctx,
self.loc.loc(),
&format!("unifying {tp} and {r}")
)
}
};
self.sub_unify_tp(&sub, maybe_sup, _variance, allow_divergence)
}
(l, r) => {
log!(err "{l} / {r}");
type_feature_error!(self.ctx, self.loc.loc(), &format!("unifying {l} and {r}"))