Skip to content

Commit

Permalink
Merge pull request #1 from nubank/swift_4.1
Browse files Browse the repository at this point in the history
Makes Freddy compatible with Swift 4.1
  • Loading branch information
brunopinheiro authored Oct 10, 2018
2 parents b416633 + dacc80c commit 6277430
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Sources/IntExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Foundation
}

func addingReportingOverflow(other: Int) -> (partialValue: Int, overflow: ArithmeticOverflow) {
let (exponent, overflow) = Int.addWithOverflow(self, other)
let (exponent, overflow) = self.addingReportingOverflow(other)
return (exponent, ArithmeticOverflow(overflow))
}
}
Expand Down
5 changes: 3 additions & 2 deletions Sources/JSONParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,14 @@ public struct JSONParser {
parser.parseLeadingZero()

case .preDecimalDigits:
let parserStart = parser.start
try parser.parsePreDecimalDigits { c in
guard case let (exponent, .none) = 10.multipliedReportingOverflow(other: value) else {
throw InternalError.numberOverflow(offset: parser.start)
throw InternalError.numberOverflow(offset: parserStart)
}

guard case let (newValue, .none) = exponent.addingReportingOverflow(other: Int(c - Literal.zero)) else {
throw InternalError.numberOverflow(offset: parser.start)
throw InternalError.numberOverflow(offset: parserStart)
}

value = newValue
Expand Down

0 comments on commit 6277430

Please sign in to comment.