Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-494] Cannot call function with variadic arguments before a required unnamed parameter #43111

Closed
lilyball mannequin opened this issue Jan 8, 2016 · 2 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Jan 8, 2016

Previous ID SR-494
Radar None
Original Reporter @lilyball
Type Bug
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 54dcd16)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 9c3271fc49314ea7082f4bfb393d4cff

relates to:

  • SR-2475 QoI: Warn about unlabeled parameters following a variadic parameter

Issue 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.

@belkadan
Copy link
Contributor

belkadan commented Jan 8, 2016

cwillmore (JIRA User), seems like something you'd be interested in (at some point).

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis
Copy link
Collaborator

Fixed and covered by tests here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants