Did the subtyping rules for tuple labels change in Swift 6?

i attempted to build the swift-png package with a nightly Swift 6.0 compiler.

Sources/LZ77/HuffmanCoding/LZ77.HuffmanTree.swift:95:63: error: cannot convert sequence element type '(offset: Int, element: Range<Int>)' to expected type '(Int, Range<Int>)'
 93 |         var z:Int       = 256 // n
 94 |         // finish validating the tree
 95 |         for (i, leaves):(Int, Range<Int>) in levels[8 ..< 15].enumerated()
    |                                                               `- error: cannot convert sequence element type '(offset: Int, element: Range<Int>)' to expected type '(Int, Range<Int>)'
 96 |         {

it seems it is no longer allowed to ignore tuple labels when binding to an unlabeled tuple. was this by design?

6 Likes

This is definitely a bug, here is a reduction:

func size(_ levels:[Range<Int>]) {
  for (i, leaves):(Int, Range<Int>) in levels[8 ..< 15].enumerated() {
  }
}

Looks like the solver bindings a type variable that represents an object type of an optional produced by next() before the wrapped type itself.

7 Likes

i have filed it here:

4 Likes