pointfreeco/swift-parsing

utf8 parsing allows numbers larger that a Float to be "successfully" parsed.

ryanbooker opened this issue · 3 comments

I noticed testFloat fails on my local machines (M1 & Intel, Big Sur 11.3 Betas, release Xcode):

    input = "1234567890123456789012345678901234567890 Hello"[...].utf8
    XCTAssertEqual(nil, parser.parse(&input))
    XCTAssertEqual("1234567890123456789012345678901234567890 Hello", String(input))

Parsing consumes the number, returning: Optional(inf).

It doesn't appear to fail on CI…?

Maybe something like this to protect against overflows: #25

UInt8("1234567890123456789012345678901234567890") // nil
Float("1234567890123456789012345678901234567890") // inf

I'm only seeing this in Xcode 12.5 Betas at the moment. Probably worth ignoring for now. :)

Closed in favour of following Apple and letting inf be successfully parsed.