diff --git a/src/floats.jl b/src/floats.jl index d6ec4b5..b5ce7be 100644 --- a/src/floats.jl +++ b/src/floats.jl @@ -291,6 +291,11 @@ end if negexp || b == UInt8('+') pos += 1 incr!(source) + if eof(source, pos, len) + # it's an error to have a "dangling" '-' or '+', so input was something like "1.1e-" + code |= INVALID | EOF + @goto done + end end b = peekbyte(source, pos) - UInt8('0') if b > 0x09 diff --git a/test/floats.jl b/test/floats.jl index 820a35e..c2c7217 100644 --- a/test/floats.jl +++ b/test/floats.jl @@ -363,4 +363,7 @@ for _ = 1:1000 @test Base.parse(Float16, str) === Parsers.parse(Float16, str) end +# discovered from JSON tests +@test Parsers.tryparse(Float64, "0e+") === nothing + end # @testset