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
10 changes: 5 additions & 5 deletions lib/Parse/ParseStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,17 +1179,17 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
if (Tok.isAny(tok::oper_binary_spaced, tok::oper_binary_unspaced) &&
Tok.getText() == "&&") {
diagnose(Tok, diag::expected_comma_stmtcondition)
.fixItReplace(Tok.getLoc(), ",");
.fixItReplaceChars(getEndOfPreviousLoc(), Tok.getRange().getEnd(), ",");
consumeToken();
return true;
}

// Boolean conditions are separated by commas, not the 'where' keyword, as
// they were in Swift 2 and earlier.
SourceLoc whereLoc;
if (consumeIf(tok::kw_where, whereLoc)) {
diagnose(whereLoc, diag::expected_comma_stmtcondition)
.fixItReplace(whereLoc, ",");
if (Tok.is(tok::kw_where)) {
diagnose(Tok, diag::expected_comma_stmtcondition)
.fixItReplaceChars(getEndOfPreviousLoc(), Tok.getRange().getEnd(), ",");
consumeToken();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion test/Parse/availability_query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if !#available(OSX 10.52, *) { // expected-error {{#available may only be used a
if let _ = Optional(5), !#available(OSX 10.52, *) { // expected-error {{#available may only be used as condition}}
}

if #available(OSX 10.51, *) && #available(OSX 10.52, *) { // expected-error {{expected ',' joining parts of a multi-clause condition}} {{29-31=,}}
if #available(OSX 10.51, *) && #available(OSX 10.52, *) { // expected-error {{expected ',' joining parts of a multi-clause condition}} {{28-31=,}}
}


Expand Down
2 changes: 1 addition & 1 deletion test/Parse/recovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func f1() {

// <rdar://problem/20489838> QoI: Nonsensical error and fixit if "let" is missing between 'if let ... where' clauses
func testMultiPatternConditionRecovery(x: Int?) {
// expected-error@+1 {{expected ',' joining parts of a multi-clause condition}} {{16-21=,}}
// expected-error@+1 {{expected ',' joining parts of a multi-clause condition}} {{15-21=,}}
if let y = x where y == 0, let z = x {
_ = y
_ = z
Expand Down
7 changes: 4 additions & 3 deletions test/stmt/statements.swift
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,12 @@ func f21080671() {
// <rdar://problem/24467411> QoI: Using "&& #available" should fixit to comma
// https://twitter.com/radexp/status/694561060230184960
func f(_ x : Int, y : Int) {
if x == y && #available(iOS 52, *) {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{13-15=,}}
if #available(iOS 52, *) && x == y {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{28-30=,}}
if x == y && #available(iOS 52, *) {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{12-15=,}}
if #available(iOS 52, *) && x == y {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{27-30=,}}

// https://twitter.com/radexp/status/694790631881883648
if x == y && let _ = Optional(y) {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{13-15=,}}
if x == y && let _ = Optional(y) {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{12-15=,}}
if x == y&&let _ = Optional(y) {} // expected-error {{expected ',' joining parts of a multi-clause condition}} {{12-14=,}}
}


Expand Down