swift 4 compiler error tuple parameter does not support destructing

I have the following code snippet that compile OK in swift 3

        bytes = Array\(UnsafeBufferPointer\(\.\.\.\.\)\)
        let filenamelength = bytes\[\(i\+28\)\.\.<\(i\+28\+2\)\]
            \.enumerated\(\)
            \.map \{ \(index, element\) in return Int\(Double\(element\) \* pow\(256,Double\(index\)\)\) \}
            \.reduce\(0, \+\)

I have the following code snippet that compile OK in swift 3
In Swift 4 (Xcode beta1) it compiled with error something like "... too complex"
Now in Swift 4 Xocde beta2 the error is tuple parameter element does not support destructing
what has been changed in swift 4 ?

Please help how to solve it ?

Thanks

This is due to SE-0110:
  https://github.com/apple/swift-evolution/blob/master/proposals/0110-distingish-single-tuple-arg.md
but see the additional commentary:
  [swift-evolution-announce] [Core team] Addressing the SE-0110 usability regression in Swift 4

For now you can rewrite it as:

let filenamelength = bytes
  .enumerated()
  .map {
    let (index, element) = $0
    return Int(Double(element) * pow(256,Double(index))) }
  .reduce(0, +)

- Daniel

ยทยทยท

On Jun 29, 2017, at 8:08 PM, CK TUNG via swift-users <swift-users@swift.org> wrote:

I have the following code snippet that compile OK in swift 3

            bytes = Array(UnsafeBufferPointer(....))
            let filenamelength = bytes[(i+28)..<(i+28+2)]
                .enumerated()
                .map { (index, element) in return Int(Double(element) * pow(256,Double(index))) }
                .reduce(0, +)

I have the following code snippet that compile OK in swift 3
In Swift 4 (Xcode beta1) it compiled with error something like "... too complex"
Now in Swift 4 Xocde beta2 the error is tuple parameter element does not support destructing
what has been changed in swift 4 ?

Please help how to solve it ?

Thanks

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users