Skip to content

[SR-128] Pass array to variadic function #42750

@swift-ci

Description

@swift-ci
Previous ID SR-128
Radar rdar://problem/12134482
Original Reporter arthur (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 39
Component/s Compiler
Labels Improvement, LanguageFeatureRequest
Assignee None
Priority Medium

md5: fe683ee214998d48375c8fbaf79fbfbc

is duplicated by:

  • SR-1644 Issue with varargs
  • SR-4386 variadic parameters are interpreted as single argument when passed on
  • SR-9733 No Syntax for Array Splat

relates to:

  • SR-8047 compiler should warn when implicitly casting Array to CVarArg

Issue Description:

func a(p: Int...) {
    p is [Int] // true
}

a(1, 2, 3) // Works
a([1, 2, 3]) // error: cannot invoke 'a' with an argument list of type '([Int])'

I want to pass an array into a function that accepts a variadic argument, as within the scope of the function, the argument p, is treated as an array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itselfimprovementswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalvariadic parametersFeature → declarations → function parameters: Variadic function parameters
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions