Add missing unify rules for inference variables

Inference variables can unify with anything so this includes these
covariant types like references/slices etc. This patch is needed for more
complex type-checking in libcore and generics.
This commit is contained in:
Philip Herron 2022-04-12 13:20:14 +01:00
parent a5b38698aa
commit 7609dfc63e
1 changed files with 60 additions and 0 deletions

View File

@ -867,6 +867,18 @@ public:
TyVar (base_resolved->get_ref ()));
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }
@ -896,6 +908,18 @@ public:
TyVar (base_resolved->get_ref ()));
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }
@ -1140,6 +1164,18 @@ public:
type.get_ident ().locus, fields);
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }
@ -1263,6 +1299,18 @@ public:
base->mutability ());
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }
@ -1303,6 +1351,18 @@ public:
base->mutability ());
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }