Return type of a function that takes pack crashes the compiler

Not sure if this is a real limitation or a (known) bug.

protocol P {}

struct S<each T>: P {

    let value: (repeat each T)
}

func s<each T>(_ value: repeat each T) -> S<repeat each T> {
    S(value: (repeat each value))
}

func p<each T>(_ value: repeat each T) -> some P {
    S(value: (repeat each value))
}

func noResult<each T>(_ value: repeat each T) {
    _ = S(value: (repeat each value))
}

p and noResult functions crashes the compiler. I've tried Xcode 15.2 beta (15C5500c) and swift-5.10-DEVELOPMENT-SNAPSHOT-2023-12-21-a.xctoolchain, no luck. Can anyone enlighten me on what's wrong (with Swift or me)?

Whether or not there's an issue in your code, the compiler should not crash. Please report the bug.

A bug report can pretty much be just what you wrote here; "hey, I tried to compile the following code with this version of the compiler and it crashed ..."

2 Likes

It looks like your test case compiles successfully with some fixes I'm working on: Fix openType() handling of parameter packs by slavapestov · Pull Request #70457 · apple/swift · GitHub. However if you don't mind, please file an issue anyway -- it will remind me to make sure the existing tests cover your case, Also you will receive a notification when the PR is merged and you can try a new snapshot.

3 Likes

Filed! Thank you, Slava, for looking into this. I am looking forward to the fix!

2 Likes