bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 120 forks source link

JSONParser.swift uses deprecated API when compiled against Swift 4.1 #275

Closed alanzeino closed 6 years ago

alanzeino commented 6 years ago
JSONParser.swift:187:21: error: 'index(_:offsetBy:limitedBy:)' is deprecated: all index distances are now of type Int
        guard input.index(loc, offsetBy: 3, limitedBy: input.count) != input.count else {
                    ^
JSONParser.swift:202:21: error: 'index(_:offsetBy:limitedBy:)' is deprecated: all index distances are now of type Int
        guard input.index(loc, offsetBy: 3, limitedBy: input.count) != input.count else {
                    ^
JSONParser.swift:217:21: error: 'index(_:offsetBy:limitedBy:)' is deprecated: all index distances are now of type Int
        guard input.index(loc, offsetBy: 4, limitedBy: input.count) != input.count else {
                    ^
zwaldowski commented 6 years ago

This looks like a source compatibility bug, the code as written should be able to use the new Int-based overloads just fine. I'll look around to see if it's been reported yet.

alanzeino commented 6 years ago

Important to note; we use -Werror and SWIFT_WARNINGS_AS_ERRORS = YES. These are likely warnings being converted to errors in our codebase.

From Apple's perspective, new warnings aren't source incompatibility.

zwaldowski commented 6 years ago

new warnings aren't source incompatibility

That's true, but what I'm trying to say is that shouldn't trigger a warning: 3 should be passed as Int just like it is passed as IndexDistance right now.

alanzeino commented 6 years ago

Yeah you are right. IndexDistance is deprecated but if it's passing it as Int then this shouldn't appear.

    @available(*, deprecated, message: "all index distances are now of type Int")
    public typealias IndexDistance = Int