mirror of
https://github.com/erg-lang/erg.git
synced 2025-07-23 13:06:06 +00:00
feat: implement Structural
types
This commit is contained in:
parent
8903e84011
commit
c9dda183ab
16 changed files with 472 additions and 58 deletions
|
@ -845,6 +845,17 @@ impl Context {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
(sub, Type::Structural(sup)) => {
|
||||
let sub_fields = self.fields(sub);
|
||||
for (sup_field, sup_ty) in self.fields(sup) {
|
||||
if let Some((_, sub_ty)) = sub_fields.get_key_value(&sup_field) {
|
||||
self.sub_unify(sub_ty, &sup_ty, loc, param_name)?;
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
(
|
||||
_,
|
||||
Type::Poly {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue