Files
swift-mirror/validation-test/compiler_crashers_fixed/rdar110363503.swift
Hamish Knight 4e811c3a88 [test] Merge crasher directories
There is no longer much of a good reason to keep these separate,
merge them.
2025-10-18 12:51:30 +01:00

55 lines
1.2 KiB
Swift

// RUN: %target-swift-frontend -emit-ir %s -disable-availability-checking
struct ZipCollection<each C: Collection> {
let c: (repeat each C)
}
extension ZipCollection: Collection {
struct Element {
var elt: (repeat (each C).Element)
}
struct Index {
let i: (repeat (each C).Index)
}
var startIndex: Index {
Index(i: (repeat (each c).startIndex))
}
var endIndex: Index {
Index(i: (repeat (each c).endIndex))
}
func index(after i: Index) -> Index {
Index(i: (repeat (each c).index(after: each i.i)))
}
subscript(index: Index) -> Element {
Element(elt: (repeat (each c)[each index.i]))
}
}
extension ZipCollection.Index: Equatable {
static func ==(lhs: Self, rhs: Self) -> Bool {
var result = true
repeat result = ((each lhs.i) == (each rhs.i)) && result
return result
}
}
extension ZipCollection.Index: Comparable {
static func <(lhs: Self, rhs: Self) -> Bool {
var result: Bool? = nil
func check<T: Comparable>(_ x: T, _ y: T) {
if result == nil {
if x == y { return }
if x < y { result = true }
if x > y { result = false }
}
}
repeat check(each lhs.i, each rhs.i)
return result ?? false
}
}