[CSSimplify] Detect and diagnose invalid arguments for key path subscript

This commit is contained in:
Pavel Yaskevich
2023-11-22 21:05:06 -08:00
parent 32a7afc320
commit cceef44379
2 changed files with 49 additions and 1 deletions

View File

@@ -12415,8 +12415,17 @@ ConstraintSystem::simplifyKeyPathApplicationConstraint(
// Otherwise, we don't have a key path type at all.
return SolutionKind::Error;
}
if (!keyPathTy->isTypeVariableOrMember())
if (!keyPathTy->isTypeVariableOrMember()) {
if (shouldAttemptFixes()) {
auto *fix = IgnoreKeyPathSubscriptIndexMismatch::create(
*this, keyPathTy, getConstraintLocator(locator));
recordAnyTypeVarAsPotentialHole(valueTy);
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
}
return SolutionKind::Error;
}
return unsolved();
}