tayloraswift / jpeg

decode, inspect, edit, and encode jpeg images in pure swift
https://kelvin13.github.io/jpeg/
Mozilla Public License 2.0
142 stars 17 forks source link

Swift 6 compile errors #16

Closed valeriyvan closed 3 days ago

valeriyvan commented 5 days ago
swift build    
Building for debugging...
/Users/***/jpeg/sources/jpeg/encode.swift:219:45: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
 217 |             let limit:SIMD8<Float>  = .init(repeating: 
 218 |                 .init(sign: .plus, exponent: precision    , significand: 1)) - 1
 219 |             for (x, y):(Int, Int) in (0, 0) ..< plane.units
     |                                             `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
 220 |             {
 221 |                 let g:Block8x8<Float> = plane.load(x: x, y: y, limit: limit), 

/Users/***/jpeg/sources/jpeg/encode.swift:326:45: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
 324 |         return .init(unsafeUninitializedCapacity: 64)
 325 |         {
 326 |             for (k, h):(Int, Int) in (0, 0) ..< (8, 8) 
     |                                             `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
 327 |             {
 328 |                 $0[JPEG.Table.Quantization.z(k: k, h: h)] = interpolated[8 * h + k]

/Users/***/jpeg/sources/jpeg/encode.swift:405:45: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
 403 |             let response:(x:Int, y:Int) = (scale.x / factor.x, scale.y / factor.y)
 404 |             let magnitude:Float         = .init(response.x * response.y)
 405 |             for (x, y):(Int, Int) in (0, 0) ..< (8 * units.x, 8 * units.y)
     |                                             `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
 406 |             {
 407 |                 let base:(x:Int, y:Int) = 

/Users/***/jpeg/sources/jpeg/encode.swift:1270:51: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1268 |                 )
1269 |                 var predecessor:Int16 = 0
1270 |                 for (mx, my):(Int, Int) in (0, 0) ..< self.blocks 
     |                                                   `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1271 |                 {
1272 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 

/Users/***/jpeg/sources/jpeg/encode.swift:1431:51: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1429 |                 var frequencies:[Int]   = .init(repeating: 0, count: 256)
1430 |                 var predecessor:Int16   = 0
1431 |                 for (mx, my):(Int, Int) in (0, 0) ..< self.blocks 
     |                                                   `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1432 |                 {
1433 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 

/Users/***/jpeg/sources/jpeg/encode.swift:1544:43: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1542 |         
1543 |         var bits:JPEG.Bitstream = []
1544 |         for (mx, my):(Int, Int) in (0, 0) ..< self.blocks 
     |                                           `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1545 |         {
1546 |             for (p, factor):Descriptor in descriptors 
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/***/jpeg/sources/jpeg/decode.swift:3245:52: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3243 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 
3244 |                         end:(x:Int, y:Int)   = (start.x + factor.x, start.y + factor.y) 
3245 |                     for (x, y):(Int, Int) in start ..< end 
     |                                                    `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3246 |                     {
3247 |                         // dc 

/Users/***/jpeg/sources/jpeg/decode.swift:3375:52: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3373 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 
3374 |                         end:(x:Int, y:Int)   = (start.x + factor.x, start.y + factor.y) 
3375 |                     for (x, y):(Int, Int) in start ..< end 
     |                                                    `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3376 |                     {
3377 |                         let composite:JPEG.Bitstream.Composite.DC = 

/Users/***/jpeg/sources/jpeg/decode.swift:3425:57: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3423 |         let bits:JPEG.Bitstream = .init(data)
3424 |         var b:Int               = 0
3425 |         for (mx, my):(Int, Int) in (0, rows.lowerBound) ..< (self.blocks.x, rows.upperBound)
     |                                                         `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3426 |         {
3427 |             for (p, factor):Descriptor in descriptors

/Users/***/jpeg/sources/jpeg/decode.swift:3431:48: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3429 |                 let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 
3430 |                     end:(x:Int, y:Int)   = (start.x + factor.x, start.y + factor.y) 
3431 |                 for (x, y):(Int, Int) in start ..< end 
     |                                                `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3432 |                 {
3433 |                     let refinement:Int16 = try bits.refinement(&b) 

/Users/***/jpeg/sources/jpeg/encode.swift:1270:51: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1268 |                 )
1269 |                 var predecessor:Int16 = 0
1270 |                 for (mx, my):(Int, Int) in (0, 0) ..< self.blocks 
     |                                                   `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1271 |                 {
1272 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 

/Users/***/jpeg/sources/jpeg/encode.swift:1431:51: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1429 |                 var frequencies:[Int]   = .init(repeating: 0, count: 256)
1430 |                 var predecessor:Int16   = 0
1431 |                 for (mx, my):(Int, Int) in (0, 0) ..< self.blocks 
     |                                                   `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1432 |                 {
1433 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 

/Users/***/jpeg/sources/jpeg/encode.swift:1544:43: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1542 |         
1543 |         var bits:JPEG.Bitstream = []
1544 |         for (mx, my):(Int, Int) in (0, 0) ..< self.blocks 
     |                                           `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
1545 |         {
1546 |             for (p, factor):Descriptor in descriptors 
/Users/***/jpeg/sources/jpeg/decode.swift:332:56: error: cannot convert sequence element type '(offset: Int, element: Int)' to expected type '(Int, Int)'
 330 |         var z:Int      = n
 331 |         // finish validating the tree 
 332 |         for (i, leaves):(Int, Int) in levels[8 ..< 16].enumerated()
     |                                                        `- error: cannot convert sequence element type '(offset: Int, element: Int)' to expected type '(Int, Int)'
 333 |         {
 334 |             guard interior > 0 

/Users/***/jpeg/sources/jpeg/decode.swift:3013:55: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3011 |         let bits:JPEG.Bitstream = .init(data)
3012 |         var b:Int               = 0
3013 |         for (x, y):(Int, Int) in (0, rows.lowerBound) ..< (self.units.x, rows.upperBound)
     |                                                       `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3014 |         {
3015 |             let refinement:Int16    = try bits.refinement(&b)

/Users/***/jpeg/sources/jpeg/decode.swift:3036:55: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3034 |         var b:Int               = 0, 
3035 |             skip:Int            = 0
3036 |         for (x, y):(Int, Int) in (0, rows.lowerBound) ..< (self.units.x, rows.upperBound)
     |                                                       `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3037 |         {
3038 |             var z:Int = band.lowerBound

/Users/***/jpeg/sources/jpeg/decode.swift:3087:55: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3085 |         var b:Int               = 0, 
3086 |             skip:Int            = 0
3087 |         for (x, y):(Int, Int) in (0, rows.lowerBound) ..< (self.units.x, rows.upperBound)
     |                                                       `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3088 |         {
3089 |             var z:Int = band.lowerBound

/Users/***/jpeg/sources/jpeg/decode.swift:3245:52: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3243 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 
3244 |                         end:(x:Int, y:Int)   = (start.x + factor.x, start.y + factor.y) 
3245 |                     for (x, y):(Int, Int) in start ..< end 
     |                                                    `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3246 |                     {
3247 |                         // dc 

/Users/***/jpeg/sources/jpeg/decode.swift:3375:52: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3373 |                     let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 
3374 |                         end:(x:Int, y:Int)   = (start.x + factor.x, start.y + factor.y) 
3375 |                     for (x, y):(Int, Int) in start ..< end 
     |                                                    `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3376 |                     {
3377 |                         let composite:JPEG.Bitstream.Composite.DC = 

/Users/***/jpeg/sources/jpeg/decode.swift:3425:57: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3423 |         let bits:JPEG.Bitstream = .init(data)
3424 |         var b:Int               = 0
3425 |         for (mx, my):(Int, Int) in (0, rows.lowerBound) ..< (self.blocks.x, rows.upperBound)
     |                                                         `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3426 |         {
3427 |             for (p, factor):Descriptor in descriptors

/Users/***/jpeg/sources/jpeg/decode.swift:3431:48: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3429 |                 let start:(x:Int, y:Int) = (     mx * factor.x,      my * factor.y), 
3430 |                     end:(x:Int, y:Int)   = (start.x + factor.x, start.y + factor.y) 
3431 |                 for (x, y):(Int, Int) in start ..< end 
     |                                                `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
3432 |                 {
3433 |                     let refinement:Int16 = try bits.refinement(&b) 

/Users/***/jpeg/sources/jpeg/decode.swift:4114:45: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
4112 |             let limit:SIMD8<Float>  = .init(repeating: 
4113 |                 .init(sign: .plus, exponent: precision    , significand: 1)) - 1
4114 |             for (x, y):(Int, Int) in (0, 0) ..< self.units 
     |                                             `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
4115 |             {
4116 |                 let h:Block8x8<Float> = self.load(x: x, y: y, quanta: q),

/Users/***/jpeg/sources/jpeg/decode.swift:4190:49: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
4188 |             interleaved     = .init(unsafeUninitializedCapacity: count)
4189 |             {
4190 |                 for (x, y):(Int, Int) in (0, 0) ..< self.size 
     |                                                 `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
4191 |                 {
4192 |                     $0[y * self.size.x + x] = self[0][x: x, y: y] 

/Users/***/jpeg/sources/jpeg/decode.swift:4210:57: error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
4208 |                     {
4209 |                         // fast path 
4210 |                         for (x, y):(Int, Int) in (0, 0) ..< self.size 
     |                                                         `- error: cannot convert sequence element type '(x: Int, y: Int)' to expected type '(Int, Int)'
4211 |                         {
4212 |                             $0[(y * self.size.x + x) * self.count + p] = plane[x: x, y: y]
tayloraswift commented 4 days ago

this is a known compiler bug that was fixed in May by @xedin in https://github.com/swiftlang/swift/pull/73983 . it did not make the cutoff for the Xcode beta, but should be fixed in Swift 6.

valeriyvan commented 3 days ago

closed with #17