[CS] Set the naming pattern in markInvalid

This normally gets populated by successful type-checking, we still want
to populate it if we fail though to avoid attempting to type-check the
parent statement again.
This commit is contained in:
Hamish Knight
2025-09-09 13:48:40 +01:00
parent 84847bcd06
commit 10ed17549c
3 changed files with 8 additions and 2 deletions

View File

@@ -307,6 +307,12 @@ void SyntacticElementTarget::markInvalid() const {
PreWalkResult<Pattern *> walkToPatternPre(Pattern *P) override {
P->setType(ErrorType::get(Ctx));
// For a named pattern, set it on the variable. This stops us from
// attempting to double-type-check variables we've already type-checked.
if (auto *NP = dyn_cast<NamedPattern>(P))
NP->getDecl()->setNamingPattern(NP);
return Action::Continue(P);
}