Variadic ~Escapable arguments crash the compiler

It appears to be impossible for a function to take a variable number of arguments of types that are (or may be) non-Escapable. In fact this one-liner crashes the compiler (Swift 6.3.1, macOS 26)

func takesSpans(spans: RawSpan...) -> Int {spans.count}

If I change it to an explicit array the crash goes away, but I get the expected error because Array doesn't support non-Escapable types:

func takesSpans(spans: [RawSpan]) -> Int {spans.count}
    // ERROR: Type 'RawSpan' does not conform to protocol 'Escapable'

I even tried using parameter packs, but that produced similar errors (but no crash.) Sigh.

(Should I file a bug report about the compiler crash, or is this already known?)

—Jens

3 Likes

Personally, I would open an issue.

Duplicate reports can always be closed. I'd file it just in case.

Thank you for the bug report! This was indeed an oversight in the implementation: Sema: Fix crash when declaring an old-style variadic parameter with nonescaping type by slavapestov · Pull Request #89167 · swiftlang/swift · GitHub

Usually yes, of course, but no need to anymore at this point ;)

4 Likes