Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0047-issue-43915.swift

50 lines
1008 B
Swift

// RUN: %target-swift-frontend %s -emit-ir
// https://github.com/apple/swift/issues/43915
enum SampleType: UInt8 {
case Value = 1
case Array
case Dictionary
}
protocol ByteConvertible {
init?(bytes: [UInt8], startOffset: Int)
func rawBytes() -> [UInt8]
func bytesNeeded() -> Int
}
protocol TypeRequestable {
static func containerType() -> SampleType
}
struct Sample<T, C> where T: ByteConvertible, C: TypeRequestable {
let numberOfRecords: UInt32
let sizeInBytes: UInt64
var records: [T] = [] // problem line
init(records: [T]) {
numberOfRecords = 0
sizeInBytes = 0
self.records.reserveCapacity(records.count)
self.records += records
}
}
extension Sample: ByteConvertible {
init?(bytes: [UInt8], startOffset: Int = 0) {
numberOfRecords = 0
sizeInBytes = 0
records = []
}
func rawBytes() -> [UInt8] {
return []
}
func bytesNeeded() -> Int {
return 0
}
}