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

Parameter packs cannot return single-element tuples when static and instance method names match. #79008

Open
JessyCatterwaul opened this issue Jan 29, 2025 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@JessyCatterwaul
Copy link

JessyCatterwaul commented Jan 29, 2025

Description

No response

Reproduction

enum NamedType {
  static func ƒ<each T>() -> (repeat each T) { fatalError() }
  func ƒ<each T>() -> (repeat each T) { fatalError() }
}

These compile:

NamedType.ƒ() as Void
_ = NamedType.ƒ() as (Never, Never)

This does not:

NamedType.ƒ() as Never // Cannot convert value of type '(repeat _)' to type 'Never' in coercion

Renaming one of the functions allows it to compile.

However, this is also a problem with subscripts, where renaming is of course not possible. Replacing the functions with the following will yield identical results.

struct NamedType {
  static subscript<each T>() -> (repeat each T) { fatalError() }
  subscript<each T>() -> (repeat each T) { get { fatalError() } }
}
NamedType[] as Void
_ = NamedType[] as (Never, Never)
NamedType[] as Never // Cannot convert value of type '(repeat _)' to type 'Never' in coercion

Expected behavior

Both overloads are usable.

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

@JessyCatterwaul JessyCatterwaul added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jan 29, 2025
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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant