Skip to content

Commit 17de190

Browse files
authored
Merge pull request swiftlang#28112 from CodaFi/a-noticable-lack-of-closure
Add a regression test for broken closure parameter destructuring
2 parents 1d63710 + 14e6581 commit 17de190

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/decl/func/functions.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,3 +180,21 @@ func parentheticalInout2(_ fn: (((inout Int)), Int) -> ()) {
180180
var value = 0
181181
fn(&value, 0)
182182
}
183+
184+
// SR-11724
185+
// FIXME: None of these diagnostics is particularly good.
186+
func bogusDestructuring() {
187+
struct Bar {}
188+
189+
struct Foo {
190+
func registerCallback(_ callback: @escaping ([Bar]) -> Void) {} // expected-note {{found this candidate}}
191+
func registerCallback(_ callback: @escaping ([String: Bar]) -> Void) {} // expected-note {{found this candidate}}
192+
func registerCallback(_ callback: @escaping (Bar?) -> Void) {} // expected-note {{found this candidate}}
193+
}
194+
195+
Foo().registerCallback { ([Bar]) in } // expected-error {{'<<error type>>' is not convertible to '[Bar]'}}
196+
Foo().registerCallback { ([String: Bar]) in } // expected-error {{'<<error type>>' is not convertible to '[Bar]'}}
197+
Foo().registerCallback { (Bar?) in } // expected-error {{ambiguous use of 'registerCallback'}}
198+
// expected-error@-1 {{expected parameter name followed by ':'}}
199+
// expected-error@-2 {{expected ',' separator}}
200+
}

0 commit comments

Comments
 (0)