Skip to content

Commit acdd16f

Browse files
committed
Parsed keywords as argument labels correctly, fixing diagnostic regression.
1 parent da4873b commit acdd16f

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

lib/Parse/ParseDecl.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2589,6 +2589,8 @@ bool Parser::isStartOfDecl() {
25892589
// If this is obviously not the start of a decl, then we're done.
25902590
if (!isKeywordPossibleDeclStart(Tok)) return false;
25912591

2592+
if (peekToken().is(tok::colon)) return false;
2593+
25922594
// When 'init' appears inside another 'init', it's likely the user wants to
25932595
// invoke an initializer but forgets to prefix it with 'self.' or 'super.'
25942596
// Otherwise, expect 'init' to be the start of a declaration (and complain

lib/Parse/ParseStmt.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ bool Parser::isStartOfStmt() {
6262
case tok::pound_warning:
6363
case tok::pound_error:
6464
case tok::pound_sourceLocation:
65+
if (peekToken().is(tok::colon)) return false;
6566
return true;
6667

6768
case tok::pound_line:

lib/Parse/Parser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
10171017
}
10181018
// If we're in a comma-separated list, the next token is at the
10191019
// beginning of a new line and can never start an element, break.
1020-
if (Tok.isAtStartOfLine() && !AllowSepOmission &&
1020+
if (Tok.isAtStartOfLine() &&
10211021
(Tok.is(tok::r_brace) || isStartOfDecl() || isStartOfStmt())) {
10221022
break;
10231023
}

test/Parse/invalid.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func runAction() {} // expected-note {{'runAction' declared here}}
2525

2626
// rdar://16601779
2727
func foo() {
28-
runAction(SKAction.sequence() // expected-error {{use of unresolved identifier 'SKAction'; did you mean 'runAction'?}} {{13-21=runAction}}
28+
runAction(SKAction.sequence() // expected-error {{use of unresolved identifier 'SKAction'; did you mean 'runAction'?}} {{13-21=runAction}} expected-note {{to match this opening '('}}
2929

3030
skview!
3131
// expected-error @-1 {{use of unresolved identifier 'skview'}}
32-
} // expected-error {{expected expression in list of expressions}}
32+
} // expected-error {{expected ')' in expression list}}
3333

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

test/decl/subscript/subscripting.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -304,10 +304,11 @@ func testSubscript1(_ s1 : SubscriptTest1) {
304304
// expected-error@-1 {{value of type 'SubscriptTest1' has no property or method named 'subscript'; did you mean to use the subscript operator?}}
305305
_ = s1.subscript("hello"
306306
// expected-error@-1 {{value of type 'SubscriptTest1' has no property or method named 'subscript'; did you mean to use the subscript operator?}}
307+
// expected-note@-2 {{to match this opening '('}}
307308

308309
let _ = s1["hello"]
309310
// expected-error@-1 {{ambiguous use of 'subscript(_:)'}}
310-
// expected-error@-2 {{expected expression in list of expressions}}
311+
// expected-error@-2 {{expected ')' in expression list}}
311312
}
312313

313314
struct SubscriptTest2 {

validation-test/Sema/type_checker_crashers_fixed/rdar45470505.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ extension BinaryInteger {
55

66
init<S: Sequence>(bytes: S) where S.Iterator.Element == UInt8 {
77
self.init(bytes // expected-error {{ambiguous reference to initializer 'init(_:)'}}
8+
// expected-note@-1 {{}}
89

910
extension
1011
// expected-error@-1 {{declaration is only valid at file scope}}
11-
// expected-error@-2 {{expected expression in list of expressions}}
12+
// expected-error@-2 {{expected ')' in expression list}}
1213
// expected-error@-3 {{expected '{' in extension}}
1314
}
1415
// expected-error@-1 {{expected type name in extension declaration}}

0 commit comments

Comments
 (0)