# Parameter Packs: Generic parameter 'each Value' could not be inferred

**URL:** <https://forums.swift.org/t/parameter-packs-generic-parameter-each-value-could-not-be-inferred/75039>\
**Category:** Using Swift\
**Tags:** generics, parameter-packs\
**Created:** [September 30, 2024, 1:50pm UTC](https://forums.swift.org/t/parameter-packs-generic-parameter-each-value-could-not-be-inferred/75039 "2024-09-30T13:50:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![miku1958](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/miku1958/32/11936_2.png) [@miku1958](https://forums.swift.org/u/miku1958)\
**Post date:** [September 30, 2024, 1:50pm UTC](https://forums.swift.org/t/parameter-packs-generic-parameter-each-value-could-not-be-inferred/75039/1 "2024-09-30T13:50:55Z")

</div>

I have a function like:

```swift
protocol SQLValueConvertible {
    static func value(statement: OpaquePointer, index: Int32) -> Any
}

extension String: SQLValueConvertible {
    public static func value(statement: OpaquePointer, index: Int32) -> Any {
        sqlite3_column_text(statement, index).map({ String(cString: $0) }) ?? ""
    }
}

protocol SQLiteTable {
    associatedtype StatementColumns
}

func query<Table: SQLiteTable, Value1: SQLValueConvertible, Value2: SQLValueConvertible>(table: Table) -> [Table.StatementColumns] where Table.StatementColumns == (Value1, Value2) { }

```

When I call this function

```swift
struct QueryTable: SQLiteTable {
    typealias StatementColumns = (value1: String, value2: String)
}
query(table: QueryTable())

```

It gives me these errors:

```swift
Generic parameter 'Value1' could not be inferred
Generic parameter 'Value2' could not be inferred
Instance method 'query(table:)' requires the types 'QueryTable.StatementColumns' (aka '(value1: String, value2: String)') and '(Value1, Value2)' be equivalent

```

Is this a limitation of swift? Or am I using it wrong?

---

<div class="post-metadata">

**Author:** ![bbrk24](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/bbrk24/32/27370_2.png) [@bbrk24](https://forums.swift.org/u/bbrk24)\
**Post date:** [September 30, 2024, 3:44pm UTC](https://forums.swift.org/t/parameter-packs-generic-parameter-each-value-could-not-be-inferred/75039/2 "2024-09-30T15:44:51Z")

</div>

> [@miku1958](#):
>
> requires the types 'QueryTable.StatementColumns' (aka '(value1: String, value2: String)') and '(Value1, Value2)' be equivalent

There's your answer. One is a labelled tuple and the other is an unlabelled tuple, so they aren't technically the same type.

---

<div class="post-metadata">

**Author:** ![miku1958](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/miku1958/32/11936_2.png) [@miku1958](https://forums.swift.org/u/miku1958)\
**Post date:** [October 1, 2024, 12:01am UTC](https://forums.swift.org/t/parameter-packs-generic-parameter-each-value-could-not-be-inferred/75039/3 "2024-10-01T00:01:21Z")

</div>

So it is the limitation of Swift. Thanks!

---

<div class="post-metadata">

**Author:** ![miku1958](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/miku1958/32/11936_2.png) [@miku1958](https://forums.swift.org/u/miku1958)\
**Post date:** [October 1, 2024, 12:20am UTC](https://forums.swift.org/t/parameter-packs-generic-parameter-each-value-could-not-be-inferred/75039/4 "2024-10-01T00:20:55Z")

</div>

I also tried the Parameter Packs

```swift
func query<Table: SQLiteTable, each Value: SQLValueConvertible>(table: Table) async -> [Table.StatementColumns] where Table.StatementColumns == (repeat each Value) {

```

And it give me this error:

```swift
Generic parameter 'each Value' could not be inferred
Instance method 'query(table:)' requires the types 'QueryTable.StatementColumns' (aka '(value1: String, value2: String)') and '(repeat each Value)' be equivalent

```

Looks like the same limitation
