[swift-dev] Potential Bug in SE-0029 (Remove implicit tuple splat behavior from function applications)

davesweeris at mac.com davesweeris at mac.com
Mon Apr 18 15:45:43 CDT 2016


I was updating some old code to Swift 2.2, and came across an unexpected tuple splat warning. This code is all you need to generate the deprecation warning:
public class Value<T> {
    public typealias Element = T
    public typealias Ret = T
}
public class Expression<A, R> : Value<R> {
    public typealias Arg = A
    public var args: Arg! = nil
    public subscript(arg: Arg) -> Value<Ret> { return self }
}
public class Op<A, R> : Expression<A, R> {
    public typealias OpType = Arg -> Value<R>
    public let op: OpType
    init(op: OpType) {
        self.op = op
        super.init()
    }
}
public class BinaryOp<A1, A2, R> : Op<(A1, A2), R> {
    override init(op: OpType) {
        super.init(op: op)
    }
    override public subscript(x: Arg) -> Value<Ret> {
        return op(x) //Warning: Passing 2 arguments to a callee as a single tuple value is deprecated
    }
}

I don’t understand why the compiler thinks I’m trying to splat the tuple… `op` takes one argument of type `Arg` and I’m giving it one argument of type `Arg`. In the case of a `BinaryOp`, `Arg` does happen to be a tuple, but the proposal (https://github.com/apple/swift-evolution/blob/master/proposals/0029-remove-implicit-tuple-splat.md) specifically says "it does not propose removing the ability to pass tuples as values to functions”.

Am I missing something, or have I found a bug in Swift 2.2?

- Dave Sweeris

(PS, Sorry if this is the wrong list… I’m not sure where potential bug reports go.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160418/76075a2c/attachment.html>


More information about the swift-dev mailing list