Referencing initializer 'init(_:)' on 'Range' requires that 'String.Index.Stride' conform to 'SignedInteger'

write return String(self [start ..< end]) instead of return String(self[Range(start ..< end)])

extension String {
    subscript (r: Range) -> String {
        let range = Range(uncheckedBounds: (lower: max(0, min(length, r.lowerBound)),
                                            upper: min(length, max(0, r.upperBound))))
        let start = index(startIndex, offsetBy: range.lowerBound)
        let end = index(start, offsetBy: range.upperBound - range.lowerBound)
        return String(self [start ..< end])
    }
}