fix: dict typing bugs

This commit is contained in:
Shunsuke Shibayama 2023-04-27 15:51:56 +09:00
parent 630d4d64db
commit 245d9eee84
11 changed files with 119 additions and 39 deletions

View file

@ -22,6 +22,8 @@ use Predicate as Pred;
use Type::*;
use ValueObj::{Inf, NegInf};
use super::initialize::const_func::sub_tpdict_get;
impl Context {
/// ```erg
/// occur(?T, ?T) ==> OK
@ -444,9 +446,10 @@ impl Context {
}
(TyParam::Dict(ls), TyParam::Dict(rs)) => {
for (lk, lv) in ls.iter() {
if let Some(rv) = rs.get(lk) {
if let Some(rv) = rs.get(lk).or_else(|| sub_tpdict_get(rs, lk, self)) {
self.sub_unify_tp(lv, rv, _variance, loc, allow_divergence)?;
} else {
log!(err "{rs} does not have key {lk}");
// TODO:
return Err(TyCheckErrors::from(TyCheckError::unreachable(
self.cfg.input.clone(),