Uploaded image for project: 'Swift'
  1. Swift
  2. SR-494

Cannot call function with variadic arguments before a required unnamed parameter

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

      Apple Swift version 2.1.1 (swiftlang-700.1.101.15 clang-700.1.81)
      Apple Swift version 2.2-dev (LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift 54dcd16759)

      Description

      When declaring a function that takes variadic arguments followed by a required parameter, such as

      func foo(xs: Int..., _ y: String) { print(xs, y) }
      

      this is accepted, but there's no way to call the function. Any attempt to do so fails with an error, e.g.

      foo(1, 2, "three")
      

      fails with the error

      error: missing argument for parameter #2 in call

      I consider this a bug, because this call is unambiguous. There is a single required parameter after the variadic arguments, which means that the last parameter in the call must correspond with this unnamed parameter.

      More generally, Swift should be able to figure out how to invoke functions that have one or more unnamed parameters after the variadic parameter list as long as the unnamed parameters do not have default values.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              lily Lily Ballard
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated: