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

Chaining type pack breaks type inference and fails to compile #78725

Open
stephencelis opened this issue Jan 17, 2025 · 0 comments
Open

Chaining type pack breaks type inference and fails to compile #78725

stephencelis opened this issue Jan 17, 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

@stephencelis
Copy link
Contributor

Description

When a type with a parameter pack returns a new type with a parameter pack, the type checking appears to fail to resolve the type when chained into another call.

Reproduction

struct S<T, each U> {
  func combine<V, each W>(_ other: S<V, repeat each W>) -> S<T, repeat each U, V, repeat each W> {
    fatalError()
  }

  func inspect(_: (T, repeat each U) -> Void) -> Self {
    self
  }
}

func f() {
  S<Int>().inspect { print($0) }

  let s1 = S<Int>()
  s1.inspect { print($0) }

  // ✅ This works
  let s2 = S<Int>().combine(S<Double>())
  s2.inspect { print($0, $1) }

  // 🛑 Could not infer pack element #0 from context
  // 🛑 Could not infer pack element #1 from context
  // 🛑 Could not infer pack element #2 from context
  S<Int>().combine(S<Double>()).inspect { print($0, $1) }
}

Expected behavior

I expect the line to compile since it's just combining the statements before it into a single expression

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

@stephencelis stephencelis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jan 17, 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