[Diagnostics] Diagnose that we cannot infer the key path type when binding to a hole

This commit is contained in:
Luciano Almeida
2020-05-11 18:08:40 -03:00
parent 98d3a81ede
commit 02c454c976
8 changed files with 98 additions and 4 deletions

View File

@@ -7663,6 +7663,12 @@ ConstraintSystem::simplifyKeyPathConstraint(
return true;
};
// We have a hole, the solver can't infer the key path type. So let's
// just assume this is solved.
if (shouldAttemptFixes() && keyPathTy->isHole()) {
return SolutionKind::Solved;
}
// If we're fixed to a bound generic type, trying harvesting context from it.
// However, we don't want a solution that fixes the expression type to
@@ -9482,7 +9488,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
case FixKind::CoerceToCheckedCast:
case FixKind::SpecifyObjectLiteralTypeImport:
case FixKind::AllowKeyPathRootTypeMismatch:
case FixKind::AllowCoercionToForceCast: {
case FixKind::AllowCoercionToForceCast:
case FixKind::SpecifyKeyPathRootType: {
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
}