Stupid type checking in Swift :     func cal(X: [Int], Y: [Int64]) -> Double {
        let total = Double(Y.reduce(0, +))
        var z = zip(X, Y).map { pow(Double($0), 2) * Double($1) }.reduce(0, +) / Double(total)
        return z
    }

I am getting this error

    Cannot capture 'Double' before it is declared
    Use of local variable 'Double' before its declaration

Who the hell designed this stupid typing system!? How to fix it? Thanks!