[Parse] Error if closure has an unnamed parameter

We accepted unnamed closure parameters if the type was an array literal, dictionary literal, tuple or function (because the `[` or `(` starting the type was sufficient to disambiguate the type from the parameter’s name). This was never an accepted syntax and we should disallow it.
This commit is contained in:
Alex Hoppen
2023-11-28 10:59:17 -08:00
parent 9b10ab3210
commit 4ba4da45b9
5 changed files with 10 additions and 29 deletions

View File

@@ -192,8 +192,8 @@ func bogusDestructuring() {
func registerCallback(_ callback: @escaping (Bar?) -> Void) {}
}
Foo().registerCallback { ([Bar]) in } // expected-warning {{unnamed parameters must be written with the empty name '_'}} {{29-29=_: }}
Foo().registerCallback { ([String: Bar]) in }// expected-warning {{unnamed parameters must be written with the empty name '_'}} {{29-29=_: }}
Foo().registerCallback { ([Bar]) in } // expected-error {{unnamed parameters must be written with the empty name '_'}} {{29-29=_: }}
Foo().registerCallback { ([String: Bar]) in }// expected-error {{unnamed parameters must be written with the empty name '_'}} {{29-29=_: }}
Foo().registerCallback { (Bar?) in } // expected-error {{unnamed parameters must be written with the empty name '_'}}
}