Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/AST/ASTScopeCreation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,11 +959,8 @@ AnnotatedInsertionPoint
ConditionalClausePatternUseScope::expandAScopeThatCreatesANewInsertionPoint(
ScopeCreator &scopeCreator) {
auto *initializer = sec.getInitializer();
if (!isa<ErrorExpr>(initializer)) {
scopeCreator
.constructExpandAndInsert<ConditionalClauseInitializerScope>(
this, initializer);
}
scopeCreator.constructExpandAndInsert<ConditionalClauseInitializerScope>(
this, initializer);

return {this,
"Succeeding code must be in scope of conditional clause pattern bindings"};
Expand Down
10 changes: 10 additions & 0 deletions lib/Sema/CSGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3153,6 +3153,16 @@ namespace {
}

case PatternKind::Expr: {
// Make sure we invalidate any nested VarDecls early since generating
// constraints for a `where` clause may happen before we've generated
// constraints for the ExprPattern. We'll record a fix when visiting
// the UnresolvedPatternExpr.
// FIXME: We ought to use a conjunction for switch cases, then we
// wouldn't need this logic.
auto *EP = cast<ExprPattern>(pattern);
EP->getSubExpr()->forEachUnresolvedVariable([&](VarDecl *VD) {
CS.setType(VD, ErrorType::get(CS.getASTContext()));
});
// We generate constraints for ExprPatterns in a separate pass. For
// now, just create a type variable.
return setType(CS.createTypeVariable(CS.getConstraintLocator(locator),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// {"kind":"typecheck","signature":"swift::constraints::ConstraintSystem::getTypeOfReferencePre(swift::constraints::OverloadChoice, swift::DeclContext*, swift::constraints::ConstraintLocatorBuilder, swift::constraints::PreparedOverloadBuilder*)","signatureAssert":"Assertion failed: (func->isOperator() && \"Lookup should only find operators\"), function getTypeOfReferencePre"}
// RUN: not %target-swift-frontend -typecheck %s
{
switch if .random() else {
}
{
case let !a where a:
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// {"kind":"typecheck","original":"1562769e","signature":"(anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*)"}
// RUN: not --crash %target-swift-frontend -typecheck %s
// RUN: not %target-swift-frontend -typecheck %s
enum c
func d() e {
if let
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// {"kind":"typecheck","signature":"swift::constraints::TypeVarRefCollector::walkToStmtPre(swift::Stmt*)","signatureAssert":"Assertion failed: (result), function getClosureType"}
// RUN: not %target-swift-frontend -typecheck %s
{
guard let a = (a if{
return
}
) "
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// {"kind":"typecheck","signature":"swift::constraints::TypeVarRefCollector::walkToStmtPre(swift::Stmt*)","signatureAssert":"Assertion failed: (result), function getClosureType"}
// RUN: not %target-swift-frontend -typecheck %s
{
switch if <#expression#> {
return
}
{
case let !a where a:
}
}