[ConstraintSystem] Don't re-attempt to bind type variable if it could be a hole

If type variable is allowed to be a hole and it can't be bound to
this particular (full resolved) type, just ignore this binding
instead of re-trying it later.
This commit is contained in:
Pavel Yaskevich
2020-01-24 17:07:43 -08:00
committed by Pavel Yaskevich
parent 423bcdfcdd
commit c7c9510366

View File

@@ -2249,8 +2249,17 @@ ConstraintSystem::matchTypesBindTypeVar(
// Simplify the right-hand type and perform the "occurs" check. // Simplify the right-hand type and perform the "occurs" check.
typeVar = getRepresentative(typeVar); typeVar = getRepresentative(typeVar);
type = simplifyType(type, flags); type = simplifyType(type, flags);
if (!isBindable(typeVar, type)) if (!isBindable(typeVar, type)) {
if (shouldAttemptFixes()) {
// If type variable is allowed to be a hole and it can't be bound to
// a particular (full resolved) type, just ignore this binding
// instead of re-trying it and failing later.
if (typeVar->getImpl().canBindToHole() && !type->hasTypeVariable())
return getTypeMatchSuccess();
}
return formUnsolvedResult(); return formUnsolvedResult();
}
// Since member lookup doesn't check requirements // Since member lookup doesn't check requirements
// it might sometimes return types which are not // it might sometimes return types which are not