Skip to content

Parameter pack fails to see type without explicit type info #74179

@MacAndor

Description

@MacAndor

Description

Shape recognition of parameter pack has a bug.
Errors:

Cannot convert return expression of type 'S<repeat each T>' to return type 'S<repeat each T, U>'
Pack expansion requires that 'each T' and 'repeat each T, U' have the same shape

Reproduction

struct S<each T> {

    let t: (repeat each T)

    func build<U>(_ u: U) -> S<repeat each T, U> {
        S(t: (repeat each t, u))

        // NOTE: the following works
        // S<repeat each T, U>(t: (repeat each t, u))
    }
}

Expected behavior

Return type should not require explicit type spec.

let x = S(t: ("Hello", 1))
let y = x.build(2.0)
// Expected type of y is S<String, Int, Double>

Environment

Apple Swift version 6.0-dev (LLVM 5f87d6ee2f8c800, Swift 5c01ca1)
Target: arm64-apple-macosx14.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypeResolverbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfexpressionsFeature: expressionsgenericsFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsswift 6.0swift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposaltype checkerArea → compiler: Semantic analysistype inferenceFeature: type inferenceunexpected errorBug: Unexpected error

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions