Skip to content

Commit df1e38f

Browse files
committed
[TypeChecker] NFC: Add test-case for rdar://93061432
1 parent cffa588 commit df1e38f

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
@@ -454,3 +454,32 @@ func test_fallthrough_stmt() {
454454
}
455455
}()
456456
}
457+
458+
// rdar://93061432 - No diagnostic for invalid `for-in` statement
459+
func test_missing_conformance_diagnostics_in_for_sequence() {
460+
struct Event {}
461+
462+
struct S {
463+
struct Iterator: IteratorProtocol {
464+
typealias Element = (event: Event, timestamp: Double)
465+
466+
mutating func next() -> Element? { return nil }
467+
}
468+
}
469+
470+
func fn(_: () -> Void) {}
471+
472+
func test(_ iter: inout S.Iterator) {
473+
fn {
474+
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?}}
475+
_ = v.event
476+
}
477+
}
478+
479+
fn {
480+
while let v = iter.next() { // ok
481+
_ = v.event
482+
}
483+
}
484+
}
485+
}

0 commit comments

Comments
 (0)