Skip to content

Commit 3144119

Browse files
committed
Invalidate binding VarDecls if the initializer fails to type check
Ensure to make them "typechecked".
1 parent e6ce361 commit 3144119

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,23 +2355,23 @@ bool TypeChecker::typeCheckBinding(
23552355
if (!initializer->getType())
23562356
initializer->setType(ErrorType::get(Context));
23572357

2358-
// If the type of the pattern is inferred, assign error types to the pattern
2359-
// and its variables, to prevent it from being referenced by the constraint
2360-
// system.
2358+
// Assign error types to the pattern and its variables, to prevent it from
2359+
// being referenced by the constraint system.
23612360
if (patternType->hasUnresolvedType() ||
23622361
patternType->hasUnboundGenericType()) {
23632362
pattern->setType(ErrorType::get(Context));
2364-
pattern->forEachVariable([&](VarDecl *var) {
2365-
// Don't change the type of a variable that we've been able to
2366-
// compute a type for.
2367-
if (var->hasInterfaceType() &&
2368-
!var->getType()->hasUnboundGenericType() &&
2369-
!var->isInvalid())
2370-
return;
2371-
2372-
var->setInvalid();
2373-
});
23742363
}
2364+
2365+
pattern->forEachVariable([&](VarDecl *var) {
2366+
// Don't change the type of a variable that we've been able to
2367+
// compute a type for.
2368+
if (var->hasInterfaceType() &&
2369+
!var->getType()->hasUnboundGenericType() &&
2370+
!var->isInvalid())
2371+
return;
2372+
2373+
var->setInvalid();
2374+
});
23752375
return true;
23762376
}
23772377

0 commit comments

Comments
 (0)