Skip to content

[SE-0099 Restructuring Condition Clauses] Flip the switch #3441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2016
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
7 changes: 1 addition & 6 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -803,13 +803,8 @@ ERROR(expected_comma_stmtcondition,none,
ERROR(expected_expr_conditional,PointsToFirstBadToken,
"expected expression in conditional", ())

// FIXME: Upgrade these two diagnostics to errors in Swift 3.
WARNING(expected_binding_keyword,none,
ERROR(expected_binding_keyword,none,
"expected '%0' in conditional", (StringRef))
// FIXME: just replace with expected_comma_stmtcondition
WARNING(expected_comma_stmtcondition_w,none,
"expected ',' joining parts of a multi-clause condition", ())


ERROR(expected_expr_conditional_var,PointsToFirstBadToken,
"expected expression after '=' in conditional binding", ())
Expand Down
2 changes: 1 addition & 1 deletion lib/Parse/ParseStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
// they were in Swift 2 and earlier.
SourceLoc whereLoc;
if (consumeIf(tok::kw_where, whereLoc)) {
diagnose(whereLoc, diag::expected_comma_stmtcondition_w)
diagnose(whereLoc, diag::expected_comma_stmtcondition)
.fixItReplace(whereLoc, ",");
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions test/Parse/recovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,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-warning@+1 {{expected ',' joining parts of a multi-clause condition}} {{16-21=,}}
// expected-error@+1 {{expected ',' joining parts of a multi-clause condition}} {{16-21=,}}
if let y = x where y == 0, let z = x {
_ = y
_ = z
Expand All @@ -551,7 +551,7 @@ func testMultiPatternConditionRecovery(x: Int?) {
z = y; y = z
}

if var y = x, z = x { // expected-warning {{expected 'var' in conditional}} {{17-17=var }}
if var y = x, z = x { // expected-error {{expected 'var' in conditional}} {{17-17=var }}
z = y; y = z
}

Expand Down
4 changes: 2 additions & 2 deletions test/SILGen/if_while_binding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func while_loop_multi() {
// CHECK: br [[LOOP_EXIT0]]

// CHECK: [[LOOP_BODY]]([[B:%[0-9]+]] : $String):
while let a = foo(), b = bar() {
while let a = foo(), let b = bar() {
// CHECK: debug_value [[B]] : $String, let, name "b"
// CHECK: debug_value [[A]] : $String, let, name "c"
// CHECK: release_value [[B]]
Expand Down Expand Up @@ -229,7 +229,7 @@ func if_multi_where() {
// CHECK: strong_release [[BBOX]]
// CHECK: release_value [[A]]
// CHECK: br [[IF_DONE:bb[0-9]+]]
if let a = foo(), var b = bar() where a == b {
if let a = foo(), var b = bar(), a == b {
// CHECK: [[IF_BODY]]:
// CHECK: strong_release [[BBOX]]
// CHECK: release_value [[A]]
Expand Down
2 changes: 1 addition & 1 deletion test/stmt/if_while_var.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if let x = opt, let y = opt, x != y,

// Leading boolean conditional.
if 1 != 2, let x = opt,
y = opt, // expected-warning {{expected 'let' in conditional}} {{4-4=let }}
y = opt, // expected-error {{expected 'let' in conditional}} {{4-4=let }}
x != y,
let a = opt, var b = opt {
}
Expand Down