[CSDiagnostics] Diagnose situations when value pack expansion does expect a tuple argument

Diagnose situation when a single argument to tuple type is passed to
a value pack expansion parameter that expects distinct N elements:

```swift
struct S<each T> {
  func test(x: Int, _: repeat each T) {}
}

S<Int, String>().test(x: 42, (2, "b"))
```
This commit is contained in:
Pavel Yaskevich
2023-04-25 14:34:00 -07:00
committed by Pavel Yaskevich
parent b9ef2cabe4
commit c74824e1ab
3 changed files with 74 additions and 0 deletions

View File

@@ -5423,6 +5423,14 @@ ERROR(tuple_duplicate_label,none,
"cannot create a tuple with a duplicate element label", ())
ERROR(multiple_ellipsis_in_tuple,none,
"only a single element can be variadic", ())
ERROR(cannot_convert_tuple_into_pack_expansion_parameter,none,
"value pack expansion at parameter #%0 expects %1 separate arguments"
"%select{|; remove extra parentheses to change tuple into separate arguments}2",
(unsigned, unsigned, bool))
NOTE(cannot_convert_tuple_into_pack_expansion_parameter_note,none,
"value pack expansion at parameter #%0 expects %1 separate arguments",
(unsigned, unsigned))
ERROR(expansion_not_same_shape,none,
"pack expansion %0 requires that %1 and %2 have the same shape",