Skip to content

Commit d67c730

Browse files
committed
Sema: Fix logic error in TypeChecker::typeCheckPattern()
Use overwriteType() instead of setType() because we can end up with a type here if the pattern was previously marked invalid. I don't have a test for this, but its needed to fix some compiler_crashers regressions with upcoming patches.
1 parent 7521022 commit d67c730

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/Sema/TypeCheckPattern.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,8 @@ bool TypeChecker::typeCheckPattern(Pattern *P, DeclContext *dc,
784784
P->setType(ErrorType::get(Context));
785785
if (auto named = dyn_cast<NamedPattern>(P)) {
786786
if (auto var = named->getDecl()) {
787-
var->setType(ErrorType::get(Context));
787+
var->setInvalid();
788+
var->overwriteType(ErrorType::get(Context));
788789
}
789790
}
790791
return true;

0 commit comments

Comments
 (0)