Skip to content

Commit 27fc293

Browse files
committed
[JSON] expect(_:) should throw 'unexpectedEndOfFile' at EOF
1 parent 5250447 commit 27fc293

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/SwiftCompilerPluginMessageHandling/JSON/JSONDecoding.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,13 @@ private struct JSONScanner {
208208

209209
@inline(__always)
210210
mutating func expect(_ char: UnicodeScalar) throws {
211-
guard advance(if: char) else {
211+
guard hasData else {
212+
throw JSONError.unexpectedEndOfFile
213+
}
214+
guard ptr.pointee == UInt8(ascii: char) else {
212215
throw JSONError.unexpectedCharacter(ptr.pointee, context: "expected \(char)")
213216
}
217+
ptr += 1
214218
}
215219

216220
mutating func scanNull() throws {

0 commit comments

Comments
 (0)