Spot the bug in the region lookup

from Swift fundamentals
Swift 6.3.3 intermediate 4 min 3 issues to find

Find why this function can trap when its record comes from external data.

swift
func regionName(
    _ record: [String: String],
    regions: [String]
) -> String {
    let rawIndex = record["region"]!
    let index = Int(rawIndex)!
    return regions[index]
}
Open in playground
Report an error