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

Wrong warning on extension with specialized variadic type #70640

Open
dehesa opened this issue Dec 27, 2023 · 0 comments
Open

Wrong warning on extension with specialized variadic type #70640

dehesa opened this issue Dec 27, 2023 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. parameter packs Feature → generics: Parameter packs

Comments

@dehesa
Copy link

dehesa commented Dec 27, 2023

Description

After extending a variadic type with a conditional conformance, the compiler generates an incorrect warning when executing the code below. The warning refers to line:

self.characteristics = () as! (repeat each C)

and the warning states:

Cast from '()' to unrelated type '(repeat each C)' always fails

This is incorrect because the cast can succeed when C is the empty pack.

Reproduction

public struct Person<each C> {
  public var name: String
  public var characteristics: (repeat each C)
}

extension Person< >: ExpressibleByStringLiteral {
  public init(stringLiteral value: String) {
    self.name = value
    self.characteristics = () as! (repeat each C)
  }
}

let x: Person< > = "Tom Bombadil"

Expected behavior

No warning is displayed.

Environment

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0

Additional information

This has been discussed with @slavapestov in the forums.

@dehesa dehesa added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 27, 2023
@tshortli tshortli added the parameter packs Feature → generics: Parameter packs label Jan 27, 2024
@hborla hborla removed the triage needed This issue needs more specific labels label Apr 27, 2024
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. parameter packs Feature → generics: Parameter packs
Projects
None yet
Development

No branches or pull requests

3 participants