Files
swift-mirror/validation-test/compiler_crashers_fixed/0099-issue-47550.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

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]