Skip to content

Commit 68bd3d6

Browse files
committed
[Parse] Don't emit missing closing paren error if seeing any errors
1 parent f70d2d9 commit 68bd3d6

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

lib/Parse/Parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,10 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
715715
}
716716
}
717717

718-
if (parseMatchingToken(RightK, RightLoc, ErrorDiag, LeftLoc)) {
718+
if (Status.isError()) {
719+
// If we've already got errors, don't emit missing RightK diagnostics.
720+
RightLoc = Tok.is(RightK) ? consumeToken() : PreviousLoc;
721+
} else if (parseMatchingToken(RightK, RightLoc, ErrorDiag, LeftLoc)) {
719722
Status.setIsParseError();
720723
}
721724

test/Parse/invalid.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ func test2(inout let x : Int) {} // expected-error {{parameter may not have mul
1515
func test3(f : (inout _ x : Int) -> Void) {} // expected-error {{'inout' before a parameter name is not allowed, place it before the parameter type instead}}
1616

1717
func test3() {
18-
undeclared_func( // expected-error {{use of unresolved identifier 'undeclared_func'}} expected-note {{to match this opening '('}}
19-
} // expected-error {{expected expression in list of expressions}} expected-error {{expected ')' in expression list}}
18+
undeclared_func( // expected-error {{use of unresolved identifier 'undeclared_func'}}
19+
} // expected-error {{expected expression in list of expressions}}
2020

2121
func runAction() {} // expected-note {{did you mean 'runAction'?}}
2222

2323
// rdar://16601779
2424
func foo() {
25-
runAction(SKAction.sequence() // expected-error {{use of unresolved identifier 'SKAction'}} expected-note {{to match this opening '('}} expected-error {{expected ',' separator}} {{32-32=,}}
25+
runAction(SKAction.sequence() // expected-error {{use of unresolved identifier 'SKAction'}} expected-error {{expected ',' separator}} {{32-32=,}}
2626

2727
skview!
2828
// expected-error @-1 {{use of unresolved identifier 'skview'}}
29-
} // expected-error {{expected ')' in expression list}}
29+
}
3030

3131
super.init() // expected-error {{'super' cannot be used outside of class members}}
3232

@@ -38,7 +38,7 @@ switch state { // expected-error {{use of unresolved identifier 'state'}}
3838
// rdar://18926814
3939
func test4() {
4040
let abc = 123
41-
_ = " >> \( abc } ) << " // expected-note {{to match this opening '('}} expected-error {{expected ')' in expression list}} expected-error {{expected ',' separator}} {{18-18=,}} expected-error {{expected expression in list of expressions}} expected-error {{extra tokens after interpolated string expression}}
41+
_ = " >> \( abc } ) << " // expected-error {{expected ',' separator}} {{18-18=,}} expected-error {{expected expression in list of expressions}} expected-error {{extra tokens after interpolated string expression}}
4242

4343
}
4444

test/Parse/object_literals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
let _ = [##] // expected-error{{expected identifier after '#' in object literal expression}} expected-error{{object literal syntax no longer uses '[# ... #]'}} {{9-10=}} {{11-13=}}
44
let _ = [#what#] // expected-error{{object literal syntax no longer uses '[# ... #]'}} {{9-10=}} {{15-17=}}
55
let _ = [#what()#] // expected-error{{object literal syntax no longer uses '[# ... #]'}} {{9-10=}} {{17-19=}}
6-
let _ = [#colorLiteral( // expected-error@+1 {{expected expression in list of expressions}} expected-error @+1 {{expected ')' in expression list}} expected-note {{to match this opening '('}}
6+
let _ = [#colorLiteral( // expected-error@+1 {{expected expression in list of expressions}}

test/Parse/recovery.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,7 @@ case let (jeb):
523523
// rdar://19605164
524524
// expected-error@+2{{use of undeclared type 'S'}}
525525
struct Foo19605164 {
526-
func a(s: S[{{g) -> Int {} // expected-note {{to match this opening '('}}
527-
// expected-error@+3 {{expected ')' in parameter}}
526+
func a(s: S[{{g) -> Int {}
528527
// expected-error@+2 {{expected parameter name followed by ':'}}
529528
// expected-error@+1 {{expected ',' separator}}
530529
}}}

test/expr/expressions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,10 @@ func stringliterals(_ d: [String: Int]) {
457457
// expected-error @-2 {{unterminated string literal}} expected-error @-1 {{unterminated string literal}}
458458

459459
// expected-warning @+2 {{initialization of variable 'x2' was never used; consider replacing with assignment to '_' or removing it}}
460-
// expected-error @+1 {{unterminated string literal}} expected-note @+1 {{to match this opening '('}}
460+
// expected-error @+1 {{unterminated string literal}}
461461
var x2 : () = ("hello" + "
462462
;
463-
} // expected-error {{expected ')' in expression list}}
463+
}
464464
465465
func testSingleQuoteStringLiterals() {
466466
_ = 'abc' // expected-error{{single-quoted string literal found, use '"'}}{{7-12="abc"}}
@@ -689,7 +689,7 @@ func dictionaryLiterals() {
689689
func invalidDictionaryLiteral() {
690690
// FIXME: lots of unnecessary diagnostics.
691691

692-
var a = [1: ; // expected-error {{expected value in dictionary literal}} expected-error {{expected ']' in container literal expression}} expected-note {{to match this opening '['}}
692+
var a = [1: ; // expected-error {{expected value in dictionary literal}}
693693
var b = [1: ;] // expected-error {{expected value in dictionary literal}}
694694
var c = [1: "one" ;] // expected-error {{expected key expression in dictionary literal}} expected-error {{expected ',' separator}} {{20-20=,}}
695695
var d = [1: "one", ;] // expected-error {{expected key expression in dictionary literal}}

0 commit comments

Comments
 (0)