Cihat Gündüz
Cihat Gündüz

Reputation: 21468

'Cannot create a variadic tuple' error

Here's a function from the Dollar framework for Swift:

public class func bind<T, E>(function: (T...) -> E, _ parameters: T...) -> (() -> E) {
    return { () -> E in
        typealias TType = (T...)
        return function(unsafeBitCast(parameters, TType.self))
    }
}

In the line with the typealias I get the Cannot create a variadic tuple error. When I remove the braces around T... then I receive the Consecutive statements on a line must be separated by ';' error. So, this is not a solution.

Does anyone know a workaround to get the error away?

This happens since XCode 6 Beta 6, which was (really) released today.

Upvotes: 1

Views: 662

Answers (1)

Encore PTL
Encore PTL

Reputation: 8214

This is fixed in the Dollar project now. But for someone who encounters this issue in another project the way to solve it is by doing a unsafeBitCast on the function itself as such which will resolve the compile issue.

typealias Function = [T] -> E
let f = unsafeBitCast(function, Function.self)
f(params)

Upvotes: 1

Related Questions