Skip to content

Commit

Permalink
Merge pull request #34131 from MaxDesiatov/maxd/fix-SR-12994
Browse files Browse the repository at this point in the history
AST: Fix assertions crash with try expressions (main branch cherry-pick)
  • Loading branch information
akyrtzi committed Oct 1, 2020
2 parents 9348907 + fd4b01f commit 5f803ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/AST/Expr.cpp
Expand Up @@ -1943,7 +1943,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
body = body->getSemanticsProvidingExpr();

if (auto *openExistential = dyn_cast<OpenExistentialExpr>(body)) {
body = openExistential->getSubExpr();
body = openExistential->getSubExpr()->getSemanticsProvidingExpr();
}

if (auto *outerCall = dyn_cast<ApplyExpr>(body)) {
Expand All @@ -1963,7 +1963,7 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
innerBody = innerBody->getSemanticsProvidingExpr();

if (auto *openExistential = dyn_cast<OpenExistentialExpr>(innerBody)) {
innerBody = openExistential->getSubExpr();
innerBody = openExistential->getSubExpr()->getSemanticsProvidingExpr();
if (auto *ICE = dyn_cast<ImplicitConversionExpr>(innerBody))
innerBody = ICE->getSyntacticSubExpr();
}
Expand Down
12 changes: 12 additions & 0 deletions validation-test/compiler_crashers_2_fixed/sr12994.swift
@@ -0,0 +1,12 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -index-store-path %t/idx -o %t/file.o -typecheck -primary-file %s -verify

protocol MyProto {
func compile() throws
}

func compile(x: MyProto) throws {
try x.compile
// expected-error@-1 {{expression resolves to an unused function}}
// expected-warning@-2 {{no calls to throwing functions occur within 'try' expression}}
}

0 comments on commit 5f803ee

Please sign in to comment.