Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0047-sr1307.swift
Slava Pestov 412559af79 Add test cases for a few bugs that seem to be fixed already
Cleaning out some old JIRAs, don't want these to regress...
2017-01-04 02:02:29 -08:00

48 lines
960 B
Swift

// RUN: %target-swift-frontend %s -emit-ir
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
}
}