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

Compiler crash with trailing closure involving variadic types #67766

Open
xAlien95 opened this issue Aug 5, 2023 · 0 comments
Open

Compiler crash with trailing closure involving variadic types #67766

xAlien95 opened this issue Aug 5, 2023 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@xAlien95
Copy link
Contributor

xAlien95 commented Aug 5, 2023

Description
The following code is causing a compiler crash, with the error message Assertion failed: (origPackType.matchesPack(substPackType)), function PackElementGenerator, file AbstractionPattern.cpp, line 804 (Full output/stack dump).

if #available(macOS 14.0.0, *) {
  struct Tuple<each Element> {
    let element: (repeat each Element)

    init(_ element: repeat each Element) {
      self.element = (repeat each element)
    }
  }

  struct Wrapper<each Element> {
    let content: Tuple<repeat each Element>

    init(_ content: () -> Tuple<repeat each Element>) {
      self.content = content()
    }
  }

  _ = Wrapper { Tuple(1, 2) }
}

Steps to reproduce
Build the script with the latest Swift development snapshot.

Expected behavior
The compiler shouldn't crash.

Environment

  • Swift compiler version info: swift-DEVELOPMENT-SNAPSHOT-2023-08-03-a.xctoolchain, Apple Swift version 5.9-dev (LLVM 880cf58f10f5f0a, Swift f62c6c062e55591)
  • Xcode version info: Xcode 14.2, Build version 14C18
  • Deployment target: macOS 12.6.8 (21G725)

Additional context
The script compiles if you use an intermediate closure variable:

let closure = { Tuple(1, 2) }
_ = Wrapper(closure)
@xAlien95 xAlien95 added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Aug 5, 2023
@slavapestov slavapestov self-assigned this May 30, 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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

2 participants