Skip to content

Commit 0d9dc07

Browse files
committed
[TypeChecker] NFC: Add test-case for rdar://93061432
1 parent f1a2d75 commit 0d9dc07

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/expr/closure/multi_statement.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,32 @@ func test_fallthrough_stmt() {
424424
}
425425
}()
426426
}
427+
428+
// rdar://93061432 - No diagnostic for invalid `for-in` statement
429+
func test_missing_conformance_diagnostics_in_for_sequence() {
430+
struct Event {}
431+
432+
struct S {
433+
struct Iterator: IteratorProtocol {
434+
typealias Element = (event: Event, timestamp: Double)
435+
436+
mutating func next() -> Element? { return nil }
437+
}
438+
}
439+
440+
func fn(_: () -> Void) {}
441+
442+
func test(_ iter: inout S.Iterator) {
443+
fn {
444+
for v in iter.next() { // expected-error {{for-in loop requires 'S.Iterator.Element?' (aka 'Optional<(event: Event, timestamp: Double)>') to conform to 'Sequence'; did you mean to unwrap optional?}}
445+
_ = v.event
446+
}
447+
}
448+
449+
fn {
450+
while let v = iter.next() { // ok
451+
_ = v.event
452+
}
453+
}
454+
}
455+
}

0 commit comments

Comments
 (0)