Skip to content

Commit 56e9fa6

Browse files
committed
[CSGen] Fail early if pattern binding is incorrect
It's possible for `TypeChecker::typeCheckPattern` to produce either no type or type containing error. That should be detected early and immediately fail constraint generation.
1 parent e583aab commit 56e9fa6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Sema/CSGen.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,6 +3930,10 @@ bool ConstraintSystem::generateConstraints(
39303930
auto contextualPattern = ContextualPattern::forRawPattern(pattern, dc);
39313931
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
39323932

3933+
// Fail early if pattern couldn't be type-checked.
3934+
if (!patternType || patternType->hasError())
3935+
return true;
3936+
39333937
auto init = patternBinding->getInit(index);
39343938
if (!init) {
39353939
llvm_unreachable("Unsupported pattern binding entry");

0 commit comments

Comments
 (0)