Skip to content

Commit 4c06e45

Browse files
authored
Merge pull request #6319 from CodaFi/crashendo-decrashendo
Actually improve recovery when parsing bogus expressions
2 parents b5e4e8a + 443bc68 commit 4c06e45

6 files changed

+7
-7
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ ParserResult<Expr> Parser::parseExprSelector() {
661661
if (Tok.is(tok::r_paren))
662662
rParenLoc = consumeToken();
663663
else
664-
rParenLoc = Tok.getLoc();
664+
rParenLoc = PreviousLoc;
665665
} else {
666666
parseMatchingToken(tok::r_paren, rParenLoc,
667667
diag::expr_selector_expected_rparen, lParenLoc);

lib/Parse/ParsePattern.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ parseOptionalPatternTypeAnnotation(ParserResult<Pattern> result,
901901
return result;
902902

903903
Pattern *P;
904-
if (result.isNull()) // Recover by creating AnyPattern.
905-
P = new (Context) AnyPattern(Tok.getLoc());
904+
if (result.isNull())
905+
return nullptr;
906906
else
907907
P = result.get();
908908

validation-test/compiler_crashers/28522-anonymous-namespace-verifier-walktostmtpost-swift-stmt.swift renamed to validation-test/compiler_crashers_fixed/28522-anonymous-namespace-verifier-walktostmtpost-swift-stmt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
let f=[.A{#if8
1010
guard let:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
(t=#selector(

validation-test/compiler_crashers/28551-anonymous-namespace-verifier-walktostmtpost-swift-stmt.swift renamed to validation-test/compiler_crashers_fixed/28551-anonymous-namespace-verifier-walktostmtpost-swift-stmt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
#if#selector(struct r
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
#if#selector(var E{unsafeAddress{

0 commit comments

Comments
 (0)