Skip to content

"cannot pass value pack expansion to non-pack parameter" error with a variadic parameter #68755

Open
@simanerush

Description

@simanerush

Description
When passing a value pack to a function that accepts a variadic parameter, this diagnostic is emitted: cannot pass value pack expansion to non-pack parameter of type 'Any'

Steps to reproduce
Consider the following code:

func variadic<each T>(element: repeat each T) {
  print(repeat each element)
}

Expected behavior
The above code should be valid as the value parameter pack should expand into the variadic parameter Any... for the print function.

Environment

  • Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfexpressionsFeature: expressionsfunction parametersFeature → declarations: function parametersgenericsFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsswift 5.9type checkerArea → compiler: Semantic analysisunexpected errorBug: Unexpected errorvariadic parametersFeature → declarations → function parameters: Variadic function parameters

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions