[CS] Always eagerly bind member type var to hole for missing member

We know this is where the issue is so we ought to always produce a
concrete hole.
This commit is contained in:
Hamish Knight
2025-10-19 19:41:34 +01:00
parent 2a0172d25a
commit c853d81d37
4 changed files with 13 additions and 22 deletions

View File

@@ -11604,22 +11604,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
// `key path` constraint can't be retired until all components
// are simplified.
addTypeVariableConstraintsToWorkList(memberTypeVar);
} else if (isa<Expr *>(locator->getAnchor()) &&
!getSemanticsProvidingParentExpr(
getAsExpr(locator->getAnchor()))) {
// If there are no contextual expressions that could provide
// a type for the member type variable, let's default it to
// a placeholder eagerly so it could be propagated to the
// pattern if necessary.
recordTypeVariablesAsHoles(memberTypeVar);
} else if (locator->isLastElement<LocatorPathElt::PatternMatch>()) {
// Let's handle member patterns specifically because they use
// equality instead of argument application constraint, so allowing
// them to bind member could mean missing valid hole positions in
// the pattern.
recordTypeVariablesAsHoles(memberTypeVar);
} else {
recordPotentialHole(memberTypeVar);
// Eagerly turn the member type variable into a hole since we know
// this is where the issue is and we've recorded a fix for it. This
// avoids producing unnecessary holes for e.g generic parameters.
recordTypeVariablesAsHoles(memberTypeVar);
}
}