Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0099-issue-47550.swift

30 lines
640 B
Swift

// RUN: not %target-swift-frontend -typecheck -primary-file %s
// https://github.com/apple/swift/issues/47550
class IndexPath {
let item: Int
let row: Int
init(item: Int, section: Int) {
self.item = item
self.row = section
}
}
// Not valid code of course ("[Element]" would need to be "[String]")
// but compiler shouldn't crash
extension Array where Element == (String, [Element]) {
subscript(_ indexPath: IndexPath) -> String {
return self[indexPath.section].1[indexPath.row]
}
}
let collection = [("foo", ["first"])]
let indexPath = IndexPath(item: 0, section: 0)
let e = collection[indexPath]