diff --git a/Sources/IntExtensions.swift b/Sources/IntExtensions.swift index c3b53e3f..7271db8f 100644 --- a/Sources/IntExtensions.swift +++ b/Sources/IntExtensions.swift @@ -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)) } } diff --git a/Sources/JSONParser.swift b/Sources/JSONParser.swift index 61b6899d..ca516077 100644 --- a/Sources/JSONParser.swift +++ b/Sources/JSONParser.swift @@ -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