Skip to content

Commit abea719

Browse files
milsemantkremenek
authored andcommitted
[SE-0099 Restructuring Condition Clauses] Flip the switch (#3441)
Now that some time has passed, switch the warnings to errors, completing SE-0099.
1 parent e7e8b66 commit abea719

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,8 @@ ERROR(expected_comma_stmtcondition,none,
808808
ERROR(expected_expr_conditional,PointsToFirstBadToken,
809809
"expected expression in conditional", ())
810810

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

819814
ERROR(expected_expr_conditional_var,PointsToFirstBadToken,
820815
"expected expression after '=' in conditional binding", ())

lib/Parse/ParseStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ ParserStatus Parser::parseStmtCondition(StmtCondition &Condition,
11881188
// they were in Swift 2 and earlier.
11891189
SourceLoc whereLoc;
11901190
if (consumeIf(tok::kw_where, whereLoc)) {
1191-
diagnose(whereLoc, diag::expected_comma_stmtcondition_w)
1191+
diagnose(whereLoc, diag::expected_comma_stmtcondition)
11921192
.fixItReplace(whereLoc, ",");
11931193
return true;
11941194
}

test/Parse/recovery.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ func f1() {
558558

559559
// <rdar://problem/20489838> QoI: Nonsensical error and fixit if "let" is missing between 'if let ... where' clauses
560560
func testMultiPatternConditionRecovery(x: Int?) {
561-
// expected-warning@+1 {{expected ',' joining parts of a multi-clause condition}} {{16-21=,}}
561+
// expected-error@+1 {{expected ',' joining parts of a multi-clause condition}} {{16-21=,}}
562562
if let y = x where y == 0, let z = x {
563563
_ = y
564564
_ = z
@@ -568,7 +568,7 @@ func testMultiPatternConditionRecovery(x: Int?) {
568568
z = y; y = z
569569
}
570570

571-
if var y = x, z = x { // expected-warning {{expected 'var' in conditional}} {{17-17=var }}
571+
if var y = x, z = x { // expected-error {{expected 'var' in conditional}} {{17-17=var }}
572572
z = y; y = z
573573
}
574574

test/SILGen/if_while_binding.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func while_loop_multi() {
134134
// CHECK: br [[LOOP_EXIT0]]
135135

136136
// CHECK: [[LOOP_BODY]]([[B:%[0-9]+]] : $String):
137-
while let a = foo(), b = bar() {
137+
while let a = foo(), let b = bar() {
138138
// CHECK: debug_value [[B]] : $String, let, name "b"
139139
// CHECK: debug_value [[A]] : $String, let, name "c"
140140
// CHECK: release_value [[B]]
@@ -229,7 +229,7 @@ func if_multi_where() {
229229
// CHECK: strong_release [[BBOX]]
230230
// CHECK: release_value [[A]]
231231
// CHECK: br [[IF_DONE:bb[0-9]+]]
232-
if let a = foo(), var b = bar() where a == b {
232+
if let a = foo(), var b = bar(), a == b {
233233
// CHECK: [[IF_BODY]]:
234234
// CHECK: strong_release [[BBOX]]
235235
// CHECK: release_value [[A]]

test/stmt/if_while_var.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ if let x = opt, let y = opt, x != y,
6161

6262
// Leading boolean conditional.
6363
if 1 != 2, let x = opt,
64-
y = opt, // expected-warning {{expected 'let' in conditional}} {{4-4=let }}
64+
y = opt, // expected-error {{expected 'let' in conditional}} {{4-4=let }}
6565
x != y,
6666
let a = opt, var b = opt {
6767
}

0 commit comments

Comments
 (0)