Skip to content

Commit 1bd4bb9

Browse files
committed
[Diagnostics] NFC: Restore a test-case with a TODO
1 parent 260a482 commit 1bd4bb9

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

test/Constraints/diagnostics.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,23 +1183,30 @@ func sr5081() {
11831183
b = a[2...4] // expected-error {{cannot assign value of type 'ArraySlice<String>' to type '[String]'}}
11841184
}
11851185

1186-
/**
1187-
* TODO(diagnostics):Figure out what to do when expressions are complex and completely broken
1188-
*
1186+
// TODO(diagnostics):Figure out what to do when expressions are complex and completely broken
11891187
func rdar17170728() {
11901188
var i: Int? = 1
11911189
var j: Int?
11921190
var k: Int? = 2
11931191

1194-
let _ = [i, j, k].reduce(0 as Int?) {
1192+
let _ = [i, j, k].reduce(0 as Int?) { // expected-error 3 {{cannot convert value of type 'Int?' to expected element type 'Bool'}}
1193+
// expected-error@-1 {{optional type 'Int?' cannot be used as a boolean; test for '!= nil' instead}}
11951194
$0 && $1 ? $0! + $1! : ($0 ? $0! : ($1 ? $1! : nil))
1195+
// expected-error@-1 {{binary operator '+' cannot be applied to two 'Bool' operands}}
1196+
// expected-error@-2 4 {{cannot force unwrap value of non-optional type 'Bool'}}
1197+
// expected-error@-3 {{value of optional type 'Bool?' must be unwrapped to a value of type 'Bool'}}
1198+
// expected-note@-4 {{coalesce using '??' to provide a default when the optional value contains 'nil'}}
1199+
// expected-note@-5 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}}
11961200
}
11971201

1198-
let _ = [i, j, k].reduce(0 as Int?) {
1202+
let _ = [i, j, k].reduce(0 as Int?) { // expected-error 3 {{cannot convert value of type 'Int?' to expected element type 'Bool'}}
1203+
// expected-error@-1 {{missing argument label 'into:' in call}}
1204+
// expected-error@-2 {{optional type 'Int?' cannot be used as a boolean; test for '!= nil' instead}}
11991205
$0 && $1 ? $0 + $1 : ($0 ? $0 : ($1 ? $1 : nil))
1206+
// expected-error@-1 {{binary operator '+' cannot be applied to operands of type '@lvalue Bool' and 'Bool'}}
1207+
// expected-error@-2 {{'nil' cannot be used in context expecting type 'Bool'}}
12001208
}
12011209
}
1202-
*/
12031210

12041211
// https://bugs.swift.org/browse/SR-5934 - failure to emit diagnostic for bad
12051212
// generic constraints

0 commit comments

Comments
 (0)