ADT's and tuples are valid to be unified with inference variables

There is some dulication here which will eventually go away with the
coercion site refactor which is still a WIP. Here we update the type rules
so that we allow ADT's and tuples to unify and thus fulfill the type
inference rules.

Addresses #1447
This commit is contained in:
Philip Herron 2022-08-08 17:04:03 +01:00
parent 8749b66879
commit e0a14f4839
2 changed files with 36 additions and 0 deletions

View File

@ -1133,6 +1133,18 @@ public:
resolved = type.clone ();
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCoercionRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }
@ -1172,6 +1184,18 @@ public:
type.get_ident ().locus, fields);
}
void visit (InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCoercionRules::visit (type);
return;
}
resolved = base->clone ();
resolved->set_ref (type.get_ref ());
}
private:
BaseType *get_base () override { return base; }

View File

@ -1131,6 +1131,18 @@ public:
resolved = type.clone ();
}
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; }