Skip to content

Commit

Permalink
makes Freddy fork compatible with Swift 4.1
Browse files Browse the repository at this point in the history
Co-authored-by: Marcus Fonseca<marcus.080196@gmail.com>
  • Loading branch information
brunopinheiro committed Oct 9, 2018
1 parent b416633 commit dacc80c
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 dacc80c

Please sign in to comment.