Fix a python module resolving bug

This commit is contained in:
Shunsuke Shibayama 2022-12-14 06:37:43 +09:00
parent 3c17518963
commit 954c6f752d
4 changed files with 41 additions and 36 deletions

View file

@ -424,7 +424,15 @@ impl Context {
}
Type::Poly { name, mut params } => {
let typ = poly(&name, params.clone());
let (_, ctx) = self.get_nominal_type_ctx(&typ).unwrap();
let (_, ctx) = self.get_nominal_type_ctx(&typ).ok_or_else(|| {
TyCheckError::type_not_found(
self.cfg.input.clone(),
line!() as usize,
loc,
self.caused_by(),
&typ,
)
})?;
let variances = ctx.type_params_variance();
for (param, variance) in params.iter_mut().zip(variances.into_iter()) {
*param = self.deref_tp(mem::take(param), variance, loc)?;